list<S, T> static method

List<T>? list<S, T>(
  1. List<S>? source, [
  2. ArgumentEncoder<S, T>? encoder
])

Returns a List of T values from the specified list, using the given decoder to parse each value.

If the list is absent or empty, returns null (not an empty list).

Otherwise, returns a list with as many items as the specified list, with each entry in the list decoded using decoder.

If T is non-nullable, the decoder must also be non-nullable.

Implementation

static List<T>? list<S, T>(List<S>? source,
    [ArgumentEncoder<S, T>? encoder]) {
  if (source == null || source.isEmpty) {
    return null;
  }

  return source
      .map((e) => encoder == null ? (e as T) : encoder.call(e))
      .toList();
}