创建带有分隔符的开关列表磁贴

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

我正在尝试创建扑动中的开关砖的列表,这些开关砖之间具有分隔符。

我已经尝试过使用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>'"

谁创建带有分隔符的开关瓦片列表?

list listview flutter dart flutter-layout
1个回答
1
投票

请尝试这个。

.toList()添加到ListTile.divideTiles的末尾

ListTile.divideTiles(
  // all your code
  // all your code
  // all your code
).toList()
© www.soinside.com 2019 - 2024. All rights reserved.