Flutter Layout Widget之AspectRatio
AspectRatio
是一个widget,将子widget的大小指定为某个特定的宽高比
定义
const AspectRatio({
Key key,
@required this.aspectRatio,
Widget child
})
- aspectRatio → double 宽高比
new Container(
color: Colors.grey,
alignment: Alignment.center,
width: 200.0,
height: 200.0,
child: new AspectRatio(
aspectRatio: 2,
child: new Container(
color: Colors.red,
),
),
)