List<E>.generate constructor
Generates a list of values.
Creates a list with length
positions and fills it with values created by calling generator
for each index in the range 0
.. length - 1
in increasing order.
List<int>.generate(3, (int index) => index * index); // [0, 1, 4]
The created list is fixed-length if growable
is set to false.
The length
must be non-negative.
Implementation
external factory List.generate(int length, E generator(int index), {bool growable = true});
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-core/List/List.generate.html