LabeledList<E>.of constructor

LabeledList<E>.of(
  1. Iterable<E> elements, {
  2. Iterable<String?>? labels,
  3. bool growable = true,
})

Constructs a new LabeledList containing all elements.

Note: Use the LabeledList.from constructor to construct a new LabeledList that wraps and references elements.

If labels are provided, there must be a label or a null value for every element in in the list. labels.length must equal the length of the list.

If growable is false, the returned list will be a fixed-length list, otherwise the list is growable and identical to the default constructor.

Implementation

LabeledList.of(
  Iterable<E> elements, {
  Iterable<String?>? labels,
  bool growable = true,
})  : assert(labels == null || labels.length == elements.length),
      _labels = _buildLabels(labels, elements.length, growable: growable),
      super(List<E>.from(elements, growable: growable), growable: growable);