I need the items inside a for to have an action with the exception of the last one, which will have a different action
an example that DOESN’T WORK:
for (var i = 0; i < 10; i++) {
print('1 - 9');
if (i.last) {
print('last item');
}
}
I need the items inside a for to have an action with the exception of the last one, which will have a different action
an example that DOESN’T WORK:
for (var i = 0; i < 10; i++) {
print('1 - 9');
if (i.last) {
print('last item');
}
}
4
Answers
Try this:
you can try this
This is also possible, you can just paste the snippet in DartPad and play with it
Hope that will help
You can put method in the condition part of the for loop. Here is such example:
output