Range class
A numerical progression.
For basic usage, just provide the (exclusive) stop value - note that, by default, the range is exclusive of the stop value:
final range = Range(stop:5);
print(range.toList());
Result: [0, 1, 2, 3, 4]
Providing a start value allows for a non-zero starting point:
final range = Range(start: 1, stop:5);
print(range.toList());
Result: [1, 2, 3, 4]
Consider using the range() function if you just want to use a one-off range in a loop.
- Implemented types
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- start → num
-
The starting value of the range (inclusive), defaults to 0
final
- step → num
-
The step progression, defaults to 1. Must be greater than 0
final
- stop → num
-
The end value of the range (exclusive)
final
- stopExclusive → bool
-
If false, the stop value is inclusive. Defaults to true
final
Methods
-
contains(
num input) → bool -
True if
inputis between start (inclusive) and stop. -
generate(
) → Iterable< num> - Generate the values for the range.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toList(
) → List< num> - Generate all list of all values in the range.
-
toMap(
) → Map< String, dynamic> -
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override