Skip to content

Commit

Permalink
fix mapIndex return incorrect index -1.
Browse files Browse the repository at this point in the history
  • Loading branch information
JarvanMo committed Jun 12, 2022
1 parent 94e756d commit 246512b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/src/foundation/kt/collections/iterables.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ extension MapForIterable<E> on Iterable<E> {
/// var result = iterables.mapIndexed((index, element) => "$index$element"); // ["01", "12", "23", "34"]
Iterable<R> mapIndexed<R>(R Function(int index, E e) transform) {
if (this is List<E>) {
return map((e) => transform((this as List<E>).indexOf(e), e));
List<E> list = this as List<E>;
return map((e) => transform(list.indexOf(e), e));
}
var tempList = toList();
return tempList.map((e) => transform(tempList.indexOf(e), e));
Expand Down

0 comments on commit 246512b

Please sign in to comment.