Create a switch list tile with separators in flutter
1,994
Please try this.
Add .toList()
to the end of your ListTile.divideTiles
ListTile.divideTiles(
// all your code
// all your code
// all your code
).toList()
Author by
raz erez
I am raz erez from israel, i am 16 years old and i am a student/
Updated on December 19, 2022Comments
-
raz erez over 1 year
I am trying to create a list of switch tiles in flutter which have separators between the tiles.
I've tried doing this by using
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; }, ); }, ), ], ), ),
But when I tried running the code I got the following error:
"type '_SyncIterable<Widget>' is not a subtype of type 'List<Widget>'"
Who do I create a list of switch tiles with separator?
-
raz erez about 4 yearsThis has solved the bug but now the second tile is not appearing
-
encubos about 4 yearsWell, I guess that is probably something different. Review or rewrite your inside code.