flutter - 如何使小部件填充列中的剩余空间

标签 flutter dart flutter-layout

在Android中,我们可以根据TextView的大小,使ImageView尽可能多地填充空间。

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"/>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</LinearLayout>

我们如何在 Flutter 中实现这一点?假设我需要使 Datetime(green) 尽可能地填充。

new Column(
    children: <Widget>[
        new Text('Title',
            style: new TextStyle(fontWeight: FontWeight.bold)
        ),
        new Text('Datetime',
            style: new TextStyle(color: Colors.grey)
        ),
    ],
)

enter image description here

最佳答案

不是 100% 肯定,但我认为您是这个意思。 Expanded 小部件扩展到它可以使用的空间。虽然我认为它在行或列中的行为有点不同。

new Column(
children: <Widget>[
    new Text('Title',
        style: new TextStyle(fontWeight: FontWeight.bold)
    ),
    new Expanded(
        child: new Text('Datetime',
             style: new TextStyle(color: Colors.grey)
        ),
    ),
],
)

关于flutter - 如何使小部件填充列中的剩余空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49977864/

相关文章:

Flutter根据值在两种颜色之间找到颜色

firebase - 在Flutter中以表格形式查看FIrestore数据

Flutter:如何在 TabBar 中禁用特定选项卡

flutter - 如何在 flutter 中管理开关小部件的 native 外观

flutter - 在 Flutter Text Widget 中调整新行间距

ios - 我如何在Apple Store上升级iOS Flutter应用程序?

flutter - 创建一个没有空格的用户名验证器

flutter - 文本字段 flutter 的默认值?

flutter - ListTile header 内的垂直分隔线

Flutter ListView.Builder() 在可滚动列中与其他小部件