Iterator<T> class

This interface defines properties and methods for iterating over a collection; it provides the #next predicate and the #value read-only property. Some Iterators also provide key property values along with each value.

Typical usage is:

 var it = anIterableCollection.iterator;
 while (it.next()) {
   var item = it.value;
 }

Many iterators will signal an error if #next is called after the underlying collection has been modified.

To avoid confusion when dealing with Iterables, iterators implement the Iterable#iterator property by just returning themselves.

Implemented types
Available extensions
Annotations
  • @JS()
  • @staticInterop
  • @anonymous

Constructors

Iterator({Iterator? iterator, dynamic value, dynamic key, num? count, bool next()?, bool hasNext()?, dynamic first()?, void reset()?, bool any(bool (dynamic))?, bool all(bool (dynamic))?, void each(void (dynamic))?, Iterator<S> map<S>(S (dynamic))?, Iterator filter(bool (dynamic))?})
factory

Properties

all bool Function(bool (T))

Available on Iterator<T>, provided by the Iterator$Typings extension

getter/setter pair
any bool Function(bool (T))

Available on Iterator<T>, provided by the Iterator$Typings extension

getter/setter pair
count num

Available on Iterable<T>, provided by the Iterable$Typings extension

This read-only property is the number of elements in the collection.
no setter
count num

Available on Iterator<T>, provided by the Iterator$Typings extension

This read-only property is the total number of items in the iterated collection.
no setter
each ↔ void Function(void (T))

Available on Iterator<T>, provided by the Iterator$Typings extension

getter/setter pair
filter Iterator<T> Function(bool (T))

Available on Iterator<T>, provided by the Iterator$Typings extension

getter/setter pair
first ↔ T? Function()

Available on Iterable<T>, provided by the Iterable$Typings extension

getter/setter pair
first ↔ T? Function()

Available on Iterator<T>, provided by the Iterator$Typings extension

getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hasNext bool Function()

Available on Iterator<T>, provided by the Iterator$Typings extension

getter/setter pair
iterator Iterator<T>

Available on Iterable<T>, provided by the Iterable$Typings extension

Gets an Iterator that can iterate over the items in the collection.
getter/setter pair
iterator Iterator<T>

Available on Iterator<T>, provided by the Iterator$Typings extension

Returns itself, which is convenient for code that expects an Iterable instead of an Iterator. @return {Iterator.
getter/setter pair
key → dynamic

Available on Iterator<T>, provided by the Iterator$Typings extension

Gets the current index to the item in the collection, assuming #next has just returned true.
no setter
map Iterator<S> Function<S>(S (T))

Available on Iterator<T>, provided by the Iterator$Typings extension

getter/setter pair
next bool Function()

Available on Iterator<T>, provided by the Iterator$Typings extension

getter/setter pair
reset ↔ void Function()

Available on Iterator<T>, provided by the Iterator$Typings extension

getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → T

Available on Iterator<T>, provided by the Iterator$Typings extension

Gets the current item in the collection, assuming #next has just returned true.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited