mapList<E> method

List<E> mapList<E>(
  1. E toElement(
    1. T element
    )
)

Maps each element of the iterable to a new form using the provided toElement function and returns the results as a list.

Example usage:

void main() {
  List<int> numbers = [1, 2, 3, 4, 5];
  List<String> numberStrings = numbers.mapList((number) => number.toString());

  print(numberStrings); // Output: [1, 2, 3, 4, 5]
}

Implementation

List<E> mapList<E>(E Function(T element) toElement) => map(toElement).toList();