Flutter 在嵌套 Row 和 ListView 中扩展高度
我在 ListView 中有一张卡片,应该如上图所示。
//Code has been simplified by removing most theme.
ListView(
children: [
Card(
child: Row(children: [
Container(
color: Colors.red,
width: 8,
height: double.infinity, //Promblem here!!!
),
SizedBox(width: 8),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
'Detail',
),
Text('Detail'),
SizedBox(
width: double.infinity,
child: Text(
DateTime.now().toString(),
textAlign: TextAlign.end,
),
),
],
),
)
]),
),
]),
问题是红色的容器。这是一条红色垂直线作为通知。我希望它与 Row 或 Card 一样高,但保持有限的宽度,例如 4。
所以我尝试了 height: double.infinity
和 Expanded
与容器。它要么是异常,要么是溢出。 而且,尝试用 Expanded 包装 Row 会导致另一个布局异常。
那么如何让这条红色竖线有合适的高度呢?
I have a Card inside a ListView which should be like the picture above.
//Code has been simplified by removing most theme.
ListView(
children: [
Card(
child: Row(children: [
Container(
color: Colors.red,
width: 8,
height: double.infinity, //Promblem here!!!
),
SizedBox(width: 8),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
'Detail',
),
Text('Detail'),
SizedBox(
width: double.infinity,
child: Text(
DateTime.now().toString(),
textAlign: TextAlign.end,
),
),
],
),
)
]),
),
]),
The problem is the Container with red color. It's a red vertical line as a notification thing. I want it to as high as Row or Card, but keep a limited width like 4.
So I have tried height: double.infinity
and Expanded
with the Container. It's either an exception or an overflow.
And also, trying to wrap the Row with Expanded cause another layout exception.
So how to make this red vertical line have a properly height?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实现此目的的简单方法是:
Easy way to Achieve this is: