toMap method

Map<String, E> toMap()

Returns the list as a map, with the labels as keys, and the elements as values.

Any elements that don't have a label will have their index as the key.

Implementation

Map<String, E> toMap() {
  final map = <String, E>{};
  for (var i = 0; i < length; i++) {
    map.addAll({_labels[i] ?? i.toString(): elements[i]});
  }
  return map;
}