Reputation: 111
for (var i in options) Text(i);
This is my for loop, I want to know the position of i
How to find that position.
I used that for loop in Flutter Widget.
I need the solution for use the for loop inside the widgets
I want to know the position of i
Upvotes: 1
Views: 1641
Reputation: 1227
You can use it like this:
for (int index = 0; i<options.length; i++) {
var option = options[index];
Text(option);
}
Edit: Maybe a outer index variable will do.
int index = 0;
for (var i in options) {
Text(i);
index++;
}
Upvotes: 1