decodeListAs<T> static method

List<T> decodeListAs<T>(
  1. String json, {
  2. required T fromMap(
    1. Map<String, dynamic>
    ),
})

Decodes a JSON string to a list of values of type T.

Implementation

static List<T> decodeListAs<T>(
  String json, {
  required T Function(Map<String, dynamic>) fromMap,
}) {
  return (jsonDecode(json) as List<dynamic>)
      .map((e) => fromMap(e as Map<String, dynamic>))
      .toList();
}