indexed_iterable 1.1.0+2 copy "indexed_iterable: ^1.1.0+2" to clipboard
indexed_iterable: ^1.1.0+2 copied to clipboard

A simple delegate representing `Iterable`, like `List` and `set`, with index.

Simple delegate for Indexed Itrables #

This simple package offers a delegates to represent an Iterable, like List and set, to be use in a range-based for loop with an index.

Usage #

If a class to use this package is based on Iterable class, then you can use this package as follows.

See the API references for the details.

IndexedIterable #

IndexedIterable offers the ability to provide range-based loop with 0-based index for Iterables like List and `Set.

import 'package:indexed_iterable/indexed_iterable.dart';

void main() {
  final testList = [1,2,3,4,2,2,3,4];
  for(final ii in IndexedIterable(testList)) {
    print(ii.index);
    print(ii.value);
  }
}

IndexedMap #

IndexedMap offers the ability to provide range-based loop with 0-based index for Map.

import 'package:indexed_iterable/indexed_iterable.dart';
void main() {
  final testMap = {'hi':'hihi', 'bye':'byebye'};
  for(final im in IndexedMap(testMap)) {
    // im.index => 0-based index
    // im.key => key
    // im.value => value
  }
}

IndexedStream #

IndexedStream offers the ability to provide range-based async loop with 0-based index for Stream.

import 'package:indexed_iterable/indexed_iterable.dart';
void main() async {
  /// testStream => some stream you want to handle
  for(final im in IndexedStream(testStream)) {
    // im.index => 0-based index
    // im.value => value
  }
}
1
likes
30
pub points
0%
popularity

Publisher

verified publishergihwan.com

A simple delegate representing `Iterable`, like `List` and `set`, with index.

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on indexed_iterable