Stack(
alignment: AlignmentDirectional.bottomStart,
children: <Widget>[
Container(
child: Image.asset(
"images/img2.jpg",
width: (windowUtil.width - 50) / 2,
height: (windowUtil.width - 50) / 1.5,
fit: BoxFit.fill,
),
),
Container(
width: (windowUtil.width - 50) / 2,
height: (windowUtil.width - 50) / 1.5*0.9,
child: Text("1"),
decoration: BoxDecoration(color: Color(0x90000000)),
)
],
)
就是那种,一个商品view,然后在上一层的下面蒙上一个梦版,写一些信息。其实就是一个stack,但是,有一个十分重要的地方是,千万不要自己计算。
flutter 四舍五入后,你会发现尺寸不一致。
比如说alignment: Alignment(0.0,0.6)
那么,上面一层的高就应该是下面一层的0.4,但是,如果真这么计算,就会有一条误差
所以AlignmentDirectional.bottomStart就十分重要了