decodeObjects<T extends Coding> method

List<T?>? decodeObjects<T extends Coding>(
  1. String key,
  2. T? inflate()
)

Returns a list of Ts associated with key.

inflate must create an empty instance of T. The value associated with key must be a ListArchive (a List of Map). For each element of the archived list, inflate is invoked and each object in the archived list is decoded into the instance of T.

Implementation

List<T?>? decodeObjects<T extends Coding>(String key, T? Function() inflate) {
  final val = _getValue(key);
  if (val == null) {
    return null;
  }
  if (val is! List) {
    throw ArgumentError(
      "Cannot decode key '$key' as 'List<$T>', because value is not a List. Actual value: '$val'.",
    );
  }

  return val
      .map((v) => _decodedObject(v as KeyedArchive?, inflate))
      .toList()
      .cast<T?>();
}