
微信交流群
AspectRatio 是固定宽高比的组件,用法如下:
Container(
height: 300,
width: 300,
color: Colors.blue,
alignment: Alignment.center,
child: AspectRatio(
aspectRatio: 2 / 1,
child: Container(color: Colors.red,),
),
)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
aspectRatio 是宽高比,可以直接写成分数的形式,也可以写成小数的形式,但建议写成分数的形式,可读性更高。效果如下:
版权所有,禁止私自转发、克隆网站。