【问题标题】:How to make a column that fit all the screen in Flutter如何在 Flutter 中制作适合所有屏幕的列
【发布时间】:2019-09-08 05:46:59
【问题描述】:

我开始颤抖,但我不知道如何将列小部件除以 2 并使其适合所有屏幕,如图所示。

【问题讨论】:

    标签: user-interface dart flutter flutter-layout


    【解决方案1】:

    你来了

    import 'package:flutter/material.dart';
    
    void main() => runApp(MyApp());
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return Column(
          children: <Widget>[
            Expanded(child: Container(color: Colors.blue)),
            Expanded(child: Container(color: Colors.lightBlueAccent))
          ],
        );
      }
    }
    

    它是如何完成的:

    1. 我正在通过 runApp 方法运行应用程序
    2. 我创建了一个列并放置了包含颜色的容器
    3. 但是容器没有任何尺寸,所以它们是不可见的
    4. 通过扩展小部件,我让小部件知道要尽可能大。
    5. 由于我有两个展开的小部件,它们的大小相同。


    Screenshot from emulator device

    【讨论】:

      猜你喜欢
      • 2011-08-26
      • 2022-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多