【发布时间】:2019-01-29 17:38:16
【问题描述】:
我有一个内部带有 AspectRatio 小部件的小部件,当我将它放入 Expanded 时,它的尺寸不正确(这个尺寸不满足给定的 AspectRatio)。 有没有办法为 AspectRatio 获得尽可能多的空间并保持给定的 aspectRatio?
我这样做,得到 100 个单位为黄色,其他所有单位为灰色。而不是配给宽度的灰色矩形:高度等于 2.0。
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
children: <Widget>[
Container(
height: 100.0,
color: Colors.yellow,
),
Expanded(
child: AspectRatio(
aspectRatio: 2.0,
child: Container(
color: Colors.grey,
),
),
)
],
),
),
);
}
【问题讨论】:
标签: user-interface dart flutter aspect-ratio