android - 请解释一下我是 5 : What is the purpose of MainAxisSize in Flutter?

标签 android flutter dart

我很清楚 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'),
            ),
          ]),
        ),
      ),
    );
  }
}
模拟器上的输出:
enter image description here

最佳答案

假设您有一个高度为 400 的容器围绕着一个包含 3 行高度为 100 的列(由高度定义或由其中的内容定义),这使您有 100pt 的高度未使用。
MainAxisSize.max 说,在列的项目之间分配所有空间,因此在行之间创建 50 个空间。
MainAxisSize.min 说,将行挤在一起并在末尾(或开头或两端,取决于对齐方式)留下未使用的空间(100)

关于android - 请解释一下我是 5 : What is the purpose of MainAxisSize in Flutter?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64110450/

相关文章:

java - 无法实例化 Activity 演示应用程序 Google Play 示例

android - Google Play 商店暂停应用程序?

java - 无法访问类中 protected 最终同步方法

flutter - Dart-如何在没有元素的情况下获取Iterable元素的 `runtimeType`?

dart - Flutter - 创建倒计时小部件

java - 从完全不同的类中的异步任务修改数据

flutter - Flutter AppBar 上的渐变背景

dart - 在主线程上执行Flutter异步

flutter - FutureBuilder 和 MaterialApp 的导航问题

Dartium 显示空白页