Simple range iterator.
range() method creates a Range object as follows:
range(1, 5); // [1, 2, 3, 4] range(1, 8, 2); // [1, 3, 5, 7]
Range class implements Iterable, so you can easily iterate over it:
range(0, 3).forEach((e) => print(e)); // 0, 1, 2
For creating detailed ranges, you have:
inclusiveRange(begin, end, [step]); // [begin, end] exclusiveRange(begin, end, [step]); // (begin, end) openClosedRange(begin, end, [step]); // (begin, end] closedOpenRange(begin, end, [step]); // [begin, end)
You can also create a infinite range:
inifiniteRange(begin, [step]); // [begin, infinity) openInfiniteRange(begin, [step]); // (begin, infinity) closedInfiniteRange(begin, [step]); // same as infiniteRange
If you need a type-specific range, please use:
range<int>(begin, end); inclusiveRange<int>(begin, end); range<double>(begin, end); inclusiveRange<double>(begin, end); // and so on
Add this to your package's pubspec.yaml file:
dependencies: dart_range: "^1.0.0"
You can install packages from the command line:
$ pub get
$ flutter packages get
Alternatively, your editor might support
pub get or
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
|1.0.1||Nov 10, 2017|
|1.0.0||Nov 10, 2017|
|0.0.1||Feb 4, 2015|
We analyzed this package on Mar 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Detected platforms: Flutter, web, other
No platform restriction found in primary library
Fix issues reported by
dartfmtreported 1 error 3 hints.
Strong-mode analysis of
lib/dart_range.dartfailed with the following error:
line: 149 col: 14
The argument type 'String' can't be assigned to the parameter type 'T'.
The description is too short.
Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.
Maintain an example.
Create a short demo in the
example/directory to show how to use this package. Common file name patterns include:
example.dartor you could also use
|Dart SDK||>=1.21.0 <2.0.0|