这是我想要实现的:
我创建了波纹管类以初始化和存储对象。
class WidgetItem {
SliverList sliverList;
List<StatefulBuilder> statefulBuilder;
WidgetItem(this.sliverList, this.statefulBuilder);
}
波纹管用于存储项目列表:
List<StatefulBuilder> listOfIn = [];
List<StatefulBuilder> listOfOut = [];
存储对象
List<WidgetItem> listOfItems = [];
listOfItems.add(new WidgetItem(
SliverList(
delegate: SliverChildListDelegate([
ListTile(
title: "Header 1",
),
]),
),
listOfIn));
listOfItems.add(new WidgetItem(
SliverList(
delegate: SliverChildListDelegate([
ListTile(
title: "Header 2",
),
]),
),
listOfIn));
我想显示SliverList和StatefulBuilder小部件,因为它们存储在listOfItems
中。我试图按照下面的代码创建小部件。如何实现?
return new Scaffold(
body: CustomScrollView(
slivers: <Widget>[
//show all objects from listOfObjects
list all items from `listOfItems`
]
))