class UserList extends StatelessWidget {
@override
Widget build(BuildContext context) {
final List _user = ['aa', 'bb', 'cc'];
return Container(
height: 150,
child: ListView(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
children: [
return (_user.length != 0)
? List.generate(_user.length, (index) {
return GestureDetector(
onTap: () {
print('tapped!');
},
child: Container(
decoration: new BoxDecoration(
color: Colors.blueAccent,
borderRadius: new BorderRadius.all(
const Radius.circular(40.0),
),
),
width: 150,
),
);
})
: GestureDetector(
onTap: () {
print('hehehe');
},
child: Container(
decoration: new BoxDecoration(
color: Colors.blueAccent,
borderRadius: new BorderRadius.all(
const Radius.circular(40.0),
),
),
width: 150,
child: Center(
child: Text('Whhaaaat'),
),
),
);
],
),
);
}
}
I am trying to create List of cards according to the number of users. Tried to do ...List.generate as well. If I try with ...List.generate then I receive 'Expect to find :'. I also have to add ';' which causes 'Expect to find;'.
However, I am getting type 'List<Widget>' is not a subtype of type 'Widget' error. What can I do to convert the List<Widget> to Widget type in this case?