Skip to content

Commit 246512b

Browse files
committed
fix mapIndex return incorrect index -1.
1 parent 94e756d commit 246512b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/src/foundation/kt/collections/iterables.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ extension MapForIterable<E> on Iterable<E> {
128128
/// var result = iterables.mapIndexed((index, element) => "$index$element"); // ["01", "12", "23", "34"]
129129
Iterable<R> mapIndexed<R>(R Function(int index, E e) transform) {
130130
if (this is List<E>) {
131-
return map((e) => transform((this as List<E>).indexOf(e), e));
131+
List<E> list = this as List<E>;
132+
return map((e) => transform(list.indexOf(e), e));
132133
}
133134
var tempList = toList();
134135
return tempList.map((e) => transform(tempList.indexOf(e), e));

0 commit comments

Comments
 (0)