我正在尝试创建扑动中的开关砖的列表,这些开关砖之间具有分隔符。
我已经尝试过使用ListTile.divideTiles
:
ListView(
children: ListTile.divideTiles(
context: context,
tiles: [
SwitchListTile(
secondary: Icon(Icons.signal_cellular_4_bar),
title: Text(
"First Tile",
),
value: var1,
onChanged: (bool value) {
setState(
() {
var1= value;
},
);
},
),
SwitchListTile(
secondary: Icon(Icons.swap_vert),
title: Text(
"Second Tile",
),
value: var2,
onChanged: (bool value) {
setState(
() {
var2= value;
},
);
},
),
],
),
),
但是当我尝试运行代码时,出现以下错误:
"type '_SyncIterable<Widget>' is not a subtype of type 'List<Widget>'"
谁创建带有分隔符的开关瓦片列表?
请尝试这个。
将.toList()
添加到ListTile.divideTiles
的末尾
ListTile.divideTiles(
// all your code
// all your code
// all your code
).toList()