flutter - 对两个文本小部件仅使用一次“对齐”

标签 flutter dart

Widget _createProfileContainer() {
    return new Container(
        height: 64.0,
        child: new Row(children: [
          new Expanded(
              child: new Container(
                  color: Colors.cyanAccent,
                  child: new Column(children: [
                    Align(
                        alignment: Alignment.centerLeft,
                        child: new Text("Today",
                            style: new TextStyle(
                                fontSize: 19.0, color: Colors.black))),
                    Align(
                        alignment: Alignment.centerLeft,
                        child: new Text("Thuersday, 26 March"))
                  ]))),
        ]));
  }

很好,一切正常。两个文本(今天 3月26日,星期四)在左侧对齐。但是我应用两次对齐。是否可以仅应用一次对齐?

最佳答案

您可以使用crossAxisAlignment property对齐列中的所有子项

Column(
    children: [
        Text("Today",
            style: TextStyle(
                fontSize: 19.0, color: Colors.black
            )
        ),
        Text("Thuersday, 26 March")
    ],
    crossAxisAlignment: CrossAxisAlignment.start
)

关于flutter - 对两个文本小部件仅使用一次“对齐”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60885595/

相关文章:

Flutter-如何将showModalBottomSheet设置为全高但在状态栏下方?

firebase - Flutter firebase 从真实设备连接到模拟器

Flutter 将 Draggable Scrollbar 添加到 CustomScrollView?它一直给我 'The argument type CustomScrollView can' t 被分配给 BoxScrollView'

flutter in_app_purchase '_enablePendingPurchases' : enablePendingPurchases() must be called before calling startConnection

flutter - 类型 'GeoPoint' 不是 flutter firestore 中类型 'String' 的子类型

flutter - Flutter States_Rebuilder仅更新列表中的录音带计数

flutter : `camera_android` threw an error: Binding has not yet been initialized

flutter - 所有与编译不同的 AndroidX 版本

laravel - 如何将 firebase token 传递给 Laravel 应用程序?

oop - Dart -未定义设置方法