B.A*_*yaz 1 listview list dynamic flutter flutter-layout
我正在使用颤振。我有两个可用项目和不可用项目的动态列表。我想以一种方式显示两个列表,它显示完整的可用项目列表,然后完成不可用的项目列表,flutter 将动态决定长度。
谢谢你。
这是一个小例子,应该为可用项目显示红色容器,为不可用项目显示蓝色项目。
List<int> unavailable;
List<int> available;
Expanded(
child: CustomScrollView(slivers: <Widget>[
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
final item = available[index];
if (index > available.length) return null;
return Container(color: Colors.red, height: 150.0); // you can add your available item here
},
childCount: available.length,
),
),
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
final item = unavailable[index];
if (index > unavailable.length) return null;
return Container(color: Colors.blue, height: 150.0); // you can add your unavailable item here
},
childCount: unavailable.length,
),
)
]));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2521 次 |
| 最近记录: |