FromIterableIListMixin<T> mixin

This mixin implements all Iterable methods, plus operator [], but it does NOT implement Iterable nor IList.

It is meant to help you wrap an IList into another class (composition). You must override the iter getter to return the inner IList. All other methods are efficiently implemented in terms of the iter.

Note: This class does NOT implement Iterable. Unfortunately, the expect method in tests compares Iterables by comparing its items. So if you create a class that implements Iterable and then, when you want to use the expect method, it will just compare its items, completing ignoring its operator ==.

If you need to iterate over this class, you can use the iter getter:

class MyClass with IterableLikeIListMixin<T> { ... }

MyClass obj = MyClass([1, 2, 3]);

for (int value in obj.iter) print(value);

Please note, if you really want to make your class Iterable, you can just add the implements Iterable<T> to its declaration. For example:

class MyClass with IterableLikeIListMixin<T> implements Iterable<T> { ... }

MyClass obj = MyClass([1, 2, 3]);

for (int value in obj) print(value);

See also: FromIListMixin.

Implemented types

Properties

first → T
no setter
firstOrNull → T?
no setter
hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
no setteroverride
isNotEmpty bool
no setteroverride
iter IList<T>
Classes with FromIterableIListMixin must override this.
no setter
iterator Iterator<T>
no setter
last → T
no setter
lastOrNull → T?
no setter
length int
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
single → T
no setter
singleOrNull → T?
no setter

Methods

any(Predicate<T> test) bool
cast<R>() Iterable<R>
contains(covariant T? element) bool
elementAt(int index) → T
every(Predicate<T> test) bool
expand<E>(Iterable<E> f(T)) Iterable<E>
firstWhere(Predicate<T> test, {T orElse()?}) → T
firstWhereOrNull(Predicate<T> test) → T?
fold<E>(E initialValue, E combine(E previousValue, T element)) → E
followedBy(Iterable<T> other) Iterable<T>
forEach(void f(T element)) → void
join([String separator = ""]) String
lastWhere(Predicate<T> test, {T orElse()?}) → T
map<E>(E f(T element)) Iterable<E>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reduce(T combine(T value, T element)) → T
singleWhere(Predicate<T> test, {T orElse()?}) → T
skip(int count) Iterable<T>
skipWhile(bool test(T value)) Iterable<T>
take(int count) Iterable<T>
takeWhile(bool test(T value)) Iterable<T>
toList({bool growable = true}) List<T>
toSet() Set<T>
toString() String
A string representation of this object.
override
where(Predicate<T> test) Iterable<T>
whereType<E>() Iterable<E>

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](int index) → T