UniqueList<E>.from constructor
UniqueList<E>.from (})
Creates a list containing all elements
.
The Iterator of elements
provides the order of the elements.
All the elements
should be instances of E
.
The elements
iterable itself may have any element type, so this
constructor can be used to down-cast a List
, for example as:
List<SuperType> superList = ...;
List<SubType> subList =
new List<SubType>.from(superList.whereType<SubType>());
This constructor creates a growable list when growable
is true;
otherwise, it returns a fixed-length list.
If strict
is true
, a DuplicateValuesError will be thrown when a value
is added to the list that already exists in the list.
If nullable
is true
, the list may contain multiple instances of null
,
otherwise, null
will be treated like any other value and only
one instance of null
may be contained in the list.
Implementation
factory UniqueList.from(
Iterable<E> elements, {
bool growable = true,
bool strict = false,
bool nullable = true,
}) {
final list =
_constructListFrom<E>(elements, nullable: nullable, strict: strict, growable: growable);
return UniqueList<E>._(List<E>.from(list, growable: growable),
nullable: nullable, strict: strict, growable: growable);
}