With the following code, I am trying to add a new Text
widget for each player:
Widget build(BuildContext context) {
return Container(
child: Row(children: [
Column(
children: [
for (var player in _players) {Text(player.name)}
],
)
]));
}
This results in the following error:
The element type 'Set' can't be assigned to the list type 'Widget'.
What am I doing wrong?
You are creating a Set
using the curly braces (set literal). Your build function should look exactly like this:
Widget build(BuildContext context) {
return Container(
child: Row(children: [
Column(
children: [
for (var player in _players) Text(player.name)
],
)
]));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With