In dart there any equivalent to the common:
enumerate(List) -> Iterator((index, value) => f)
or
List.enumerate() -> Iterator((index, value) => f)
or
List.map() -> Iterator((index, value) => f)
It seems that this is the easiest way but it still seems strange that this functionality wouldn't exist.
Iterable<int>.generate(list.length).forEach( (index) => {
newList.add(list[index], index)
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…