mapPosIndex<R> method
Implementation
Iterable<R> mapPosIndex<R>(
R mapper(T item, int index, IterationPosition pos)) {
int i = 0;
final length = this.length;
final isSingle = length == 1;
return [
...this.map((T item) {
final _i = i;
i++;
return mapper(
item,
_i,
isSingle
? IterationPosition.only
: _i == 0
? IterationPosition.first
: _i == length - 1
? IterationPosition.last
: IterationPosition.middle);
})
];
}