Pam*_*ela 6 android dart flutter
我很清楚 MainAxisSize 的效果,但我不明白它的目的。请像我5岁一样解释一下。谢谢。
供进一步参考:
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Color(0xffEDE7F6),
body: SafeArea(
child: Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
Container(
height: 100,
width: 100,
color: Color(0xff9575CD),
child: Text('Container 1'),
),
Container(
height: 100,
width: 100,
color: Colors.black45,
child: Text('Container 2'),
),
Container(
height: 100,
width: 100,
color: Colors.black12,
child: Text('Container 3'),
),
]),
),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
模拟器上的输出:
w46*_*461 18
假设您有一个高度为 400 的容器,包裹在包含 3 行高度为 100 的列(由高度定义或由其中的内容固有定义),这会留下 100pt 的高度未使用。
MainAxisSize.max 表示,在列的项目之间分配所有空间,因此在行之间创建 50 的空间。
MainAxisSize.min 表示,将行挤压在一起,并在末尾(或开头或两端,取决于对齐方式)留下未使用的空间 (100)
| 归档时间: |
|
| 查看次数: |
5057 次 |
| 最近记录: |