I have a list of players and I want to render this list to GridTile Buttons. How can I do this? I already tried doing a function that returns GridTiles as a list, but could not get it to work. I've already read something about maps.
My approach is, to have buttons which contain the name and the number of the player. (Player is a class i've created)
This is my example atm:
class MyHomePage extends StatelessWidget{
@override
Widget build(BuildContext context){
List<Player> players = new List<Player>();
players.add(new Player("Tom", 10, "test"));
players.add(new Player("Mike", 22, "test"));
players.add(new Player("John", 33, "test"));
List<Widget> list = new List<Widget>();
list.add(new Text("Test"));
return new Scaffold(
appBar: new AppBar(
title: new Text('Players'),
),
body: new GridView.count(
crossAxisCount: 4,
children: new List<Widget>.generate(16, (index) {
return new GridTile(
child: new Card(
color: Colors.blue.shade200,
child: new Center(
child: new Text('tile $index'),
)
),
);
}),
),
);
}
}
