由容器垂直填充ListView切片-颤振

问题描述 投票:1回答:1

我一直在尝试在我的颤振应用程序的卡的最左边放置一个线条指示器。我已经尝试了很多东西,但是没有用。

有一个确切的问题here,实际上是我一直试图解决的同一问题。

接受的解决方案的问题在于,它限制了硬编码值的高度,这是我所不希望的。而是颜色应该自动填充卡片的高度。

问题

enter image description here

我已经尝试了所有三种解决方案,但都不适合我的用例。

[C0的输出在这里,我必须将值硬编码为更大的值,以便所有显示的文本都位于其中。我觉得这不是解决方案。

first solution

Card( key: ObjectKey(noteList[index]), elevation: 2.0, child: IntrinsicHeight( child: Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ Container( width: 4, color: Color(noteList[index].intcolor), ), Flexible( flex: 100, child: ListTile( ~~~~~~~~~~~~~~~~~ SNIP ~~~~~~~~~~~~~~~~~~~~~~~~

[C0的输出这根本不显示任何内容。

chip goes outside

Second solution

[C0的输出容器没有颜色。Card( key: ObjectKey(noteList[index]), elevation: 2.0, child: Row( children: <Widget>[ Expanded( flex: 1, child: Container( constraints: BoxConstraints.expand(), color: Color(noteList[index].intcolor), ), ), Flexible( flex: 100, child: ListTile( ~~~~~~~~~~~~~~~~~ SNIP ~~~~~~~~~~~~~~~~~~~~~~~~

非常感谢。

更新1(格林尼治标准时间2020年4月6日星期一8:16 pm]

添加了代码和存储库以便于复制。

No output at all

last solution

There's no color from the container
flutter flutter-layout
1个回答
0
投票

也许一种方法是使用堆栈

Repo

输出

main.dart

© www.soinside.com 2019 - 2024. All rights reserved.