forEachIndexed method
带索引的遍历
举例:
['a', 'b', 'c'].forEachIndex((index, value) {
print('$index : $value'); // '0 : a', '1: b', '2: c'
});
Implementation
void forEachIndexed(void Function(int index, E element) action) {
var index = 0;
final iter = iterator;
while (iter.moveNext()) {
action(index++, iter.current);
}
}