1 ListView.builder(
2 itemCount: data.length,
3 itemBuilder: (context, index) {
4 return Padding(
5 padding: const EdgeInsets.symmetric(vertical: 1, horizontal: 4),
6 child: Card(
7 child: ListTile(
8 onTap: () {
9 print(data[index]);
10 },
11 title: Text(data[index].name),
12 leading: CircleAvatar(
13 backgroundImage:
14 AssetImage('assets/${data[index].avatar}'),
15 ),
16 ),
17 ),
18 );
19 }),
1ListView(
2 padding: const EdgeInsets.all(8),
3 children: <Widget>[
4 Container(
5 height: 50,
6 color: Colors.amber[600],
7 child: const Center(child: Text('Entry A')),
8 ),
9 Container(
10 height: 50,
11 color: Colors.amber[500],
12 child: const Center(child: Text('Entry B')),
13 ),
14 Container(
15 height: 50,
16 color: Colors.amber[100],
17 child: const Center(child: Text('Entry C')),
18 ),
19 ],
20)
1 Widget _myListView(BuildContext context) {
2
3 // backing data
4 final europeanCountries = ['Albania', 'Andorra', 'Armenia', 'Austria',
5 'Azerbaijan', 'Belarus', 'Belgium', 'Bosnia and Herzegovina', 'Bulgaria',
6 'Croatia', 'Cyprus', 'Czech Republic', 'Denmark', 'Estonia', 'Finland',
7 'France', 'Georgia', 'Germany', 'Greece', 'Hungary', 'Iceland', 'Ireland',
8 'Italy', 'Kazakhstan', 'Kosovo', 'Latvia', 'Liechtenstein', 'Lithuania',
9 'Luxembourg', 'Macedonia', 'Malta', 'Moldova', 'Monaco', 'Montenegro',
10 'Netherlands', 'Norway', 'Poland', 'Portugal', 'Romania', 'Russia',
11 'San Marino', 'Serbia', 'Slovakia', 'Slovenia', 'Spain', 'Sweden',
12 'Switzerland', 'Turkey', 'Ukraine', 'United Kingdom', 'Vatican City'];
13
14 return ListView.builder(
15 itemCount: europeanCountries.length,
16 itemBuilder: (context, index) {
17 return ListTile(
18 title: Text(europeanCountries[index]),
19 );
20 },
21 );
22
23 }