Repeat widget n time in Row

Viewed 1155

I am getting n as integer number from API. Then based on this n I need to add widget n number of times in Row. I am not getting correct way to implement this. I am adding screenshot to explain what I need to achieve with this.

enter image description here

That rupee icons I need to repeat number of times in Row.

1 Answers

Create a method.

List<Text> _myWidget(int count) {
  return List.generate(count, (i) => Text("*")).toList(); // replace * with your rupee or use Icon instead
}

Use it in Row for instance like this.

Row(children: _myWidget(10));
Related