create dynamic list in flutter code example
Example 1: listview in flutter
ListView(
padding: const EdgeInsets.all(8),
children: <Widget>[
Container(
height: 50,
color: Colors.amber[600],
child: const Center(child: Text('Entry A')),
),
Container(
height: 50,
color: Colors.amber[500],
child: const Center(child: Text('Entry B')),
),
Container(
height: 50,
color: Colors.amber[100],
child: const Center(child: Text('Entry C')),
),
],
)
Example 2: dynamic listview to do list flutter
body: new ListView.builder ( itemCount: litems.length, itemBuilder: (BuildContext ctxt, int index) { return new Text(litems[index]); } )
Example 3: dynamic listview to do list flutter
// A Separate Function called from itemBuilderWidget buildBody(BuildContext ctxt, int index) { return new Text(litems[index]);}body: new ListView.builder( itemCount: litems.length, itemBuilder: (BuildContext ctxt, int index) => buildBody(ctxt, index)),