Reputation: 71
Someone can help -> loop inside a row... or a solution similar. medicamentos.items[i].frequencia is like n times a day, so 24/frequencia gives me the hours to add to the medicamentos.items[i].horaInicio
children: <Widget>[
for (var i = 0; i < 24; i + (24 /medicamentos.items[i].frequencia))
{
Text( DateFormat(DateFormat.HOUR24_MINUTE, 'pt_Br')
.format(medicamentos.items[i].horaInicio
.add(Duration(hours: i))),
),
},
], ```
Upvotes: 1
Views: 1783
Reputation: 316
I am quite confusing about how frequencia
is worked here. I assume that it mean that number of something that happens in each hour?
But one thing that certain is you can just use a List.generate()
instead of loop it like this. For example:
Row(
children: List.generate(item.length, (i){
return Text(
item[i]
);
},)
),
Hope this is an answer that you are looking for.
Upvotes: 3
Reputation: 1784
I would just create a seperate list of Text widgets, and then supply the list to the children parameter of the list like this:
Widget myRow(){
List<Widget> children = [];
for(int i=0; i<4; i++){
children.add(Text("Text$i"));
}
return Row(
children: children,
);
}
Then you can add the myRow() widget to the tree like any other widget.
Upvotes: 0