C波段磁光开关:在颤振中创建带有分隔符的开关列表磁贴

关于C波段磁光开关的问题,在switchlist中经常遇到, 我试图在颤振中创建一个开关瓦片列表,这些瓦片之间有分隔符。

我试图在颤振中创建一个开关瓦片列表,这些瓦片之间有分隔符。

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

谁用分隔符创建开关磁贴列表?

1

请试试这个。

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

ListTile.divideTiles(
  // all your code
  // all your code
  // all your code
).toList()
0

你为什么不试试ListView.separated

int _selectedIndex = 0;
return ListView.separated(
  //Here's your separator
  separatorBuilder: (BuildContext context, int index) {
    return SizedBox(
      height: 10, //Whatever spacing you want.
    );
  },
  physics: BouncingScrollPhysics(),
  scrollDirection: Axis.vertical,
  shrinkWrap: true,
  itemCount: 2, //How many tiles you want
  padding: EdgeInsets.all(10),
  itemBuilder: (BuildContext context, int index) {
    return ClipRRect( //round up the edges for nicer look
      borderRadius: BorderRadius.all(Radius.circular(5)),
      //And here's your tile
      child: SwitchListTile(
        tileColor: Colors.grey[900],
        selectedTileColor: Colors.black,
        selected: index == _selectedIndex,
        value: ... ,
        onChanged: (v) {
          
             ... 
        },
        title: Text('Tile #' + index.toString()),
        subtitle: Text('-'),
      ), 
    );
  },
);

本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处

(263)
触摸屏的脚本程序怎样编写:触摸屏灵敏度(android touch screen too sensitive)
上一篇
国内cpi:计算2级缓存的CPI(calculating cpi)
下一篇

相关推荐

发表评论

登录 后才能评论

评论列表(45条)