indexed_iterable 1.1.0+2

  • Readme
  • Changelog
  • Example
  • Installing
  • 65

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.1.0+2 #

Apply dartfmt

1.1.0+1 #

Resolve type system issue

1.1.0 #

  • Add auto-complete for IndexedValue.value and IndexedValue.index.
  • Add IndexedStream for Stream and IndexedMap for `Map.

1.0.3 #

Fix value type to template.

1.0.2+1 #

Add github repository

1.0.2 #

Document works.

1.0.1 #

Resolve a dart version dependency issue.

1.0.0 #

First version of IndexedIterable

example/indexed_iterable_example.dart

import 'package:indexed_iterable/indexed_iterable.dart';

void main() async {
  final testSet = {1, 2, 3, 4, 5, 6, 7};
  final testList = [1, 2, 3, 4, 5, 6, 7];
  print('Test 1 - Indexed Set 1');
  for (final it in IndexedIterable(testSet)) {
    print(it);
  }
  print('Test 2 - Indexed List 1');
  for (final it in IndexedIterable(testList)) {
    print(it);
  }

  print('Test 3 - Indexed List 2');
  for (final it in testList.ii) {
    print(it);
  }

  print('Test 4 - Indexed Stream');
  final testStream = streamBuilder();

  await for (final ins in IndexedStream(testStream)) {
    print(ins);
  }

  print('Test 5 - IndexedMap 1');
  final testMap = {'hi': 'hihi', 'bye': 'byebye'};
  for (final im in IndexedMap(testMap)) {
    print(im);
  }
}

Stream streamBuilder() async* {
  for (var i = 0; i < 10; i++) {
    yield i * 2;
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  indexed_iterable: ^1.1.0+2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:indexed_iterable/indexed_iterable.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
31
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
Dev dependencies
pedantic ^1.8.0
test ^1.6.0