Reputation: 13
Let's say I have this string "51-47-24" and I want to split the string .split("-") so that I can create this balls:
How am I able to get that working? How can I show the splitted list in a row?
Upvotes: 1
Views: 246
Reputation: 4387
You can try to use the Row widget.
String someString = "51-47-24";
List<String> someNumbers = someString.split("-");
...
Row(
children: someNumbers.map((someNum) =>
Container(
padding: EdgeInsets.all(5.0),
child: Center(
child: Text("$someNum")
),
decoration: BoxDecoration(
color: Colors.yellow,
shape: BoxShape.circle
)
)
).toList()
)
Upvotes: 2
Reputation: 51682
Center(
child: Row(
children: '51-47-24'
.split('-')
.map((s) => CircleAvatar(
child: Text(s),
))
.toList(),
),
),
Upvotes: 2