gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 12:32:01 27 4
gpt4 key购买 nike

在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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com