List<E>.from constructor Null safety

List<E>.from(
  1. Iterable elements,
  2. {bool growable = true}
)

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<dynamic> dynList = ...some JSON value...;
List<Map<String, dynamic>> fooList =
    List.from(dynList.where((x) => x is Map && x["kind"] == "foo"));

This constructor creates a growable list when growable is true; otherwise, it returns a fixed-length list.

Implementation

external factory List.from(Iterable elements, {bool growable = true});