Flutter dart add list to children. You ListView is having Text(Widget) and a Array of ListTile(Array of Widgets) which means ListView(children: [Widget, [Widget]]).
But it should be ListView(children: [Widget1, Widget2, Widget3,…]). Below code might help
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | class MgDrawer extends StatelessWidget { @override Widget build(BuildContext context) { return StoreBuilder<AppState>( builder: (context, store) { List<Widget> list = store.state.availablePage.map((value) { return ListTile( title: Text("Title"), onTap: () {}, ); }).toList(); list.insert(0, Text("Title")); return Drawer( child: ListView( padding: EdgeInsets.zero, children: list, ), ); }, ); } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.