An interface for getting items, one at a time, from an object.

The for-in construct transparently uses Iterator to test for the end of the iteration, and to get each item (or element).

If the object iterated over is changed during the iteration, the behavior is unspecified.

The Iterator is initially positioned before the first element. Before accessing the first element the iterator must thus be advanced using moveNext to point to the first element. If no element is left, then moveNext returns false, current returns null, and all further calls to moveNext will also return false.

A typical usage of an Iterator looks as follows:

var it = obj.iterator;
while (it.moveNext()) {
  use(it.current);
}

See also: Iteration in the library tour

Implemented by

Constructors

Iterator()

Properties

current → E

Returns the current element.

read-only
hashCode int

The hash code for this object.

read-only, inherited
runtimeType Type

A representation of the runtime type of the object.

read-only, inherited

Operators

operator ==(other) bool

The equality operator.

inherited

Methods

moveNext() bool

Moves to the next element.

noSuchMethod(Invocation invocation) → dynamic

Invoked when a non-existent method or property is accessed.

inherited
toString() String

Returns a string representation of this object.

inherited