decodeList<E> method

  1. @override
List<E> decodeList<E>(
  1. String key, {
  2. int? id,
  3. Decodable<E>? using,
})
override

Decodes the data for the given key or id as a list of elements.

Optionally takes a Decodable to decode the elements of the list.

Implementation

@override
List<E> decodeList<E>(String key, {int? id, Decodable<E>? using}) {
  try {
    final v = _value[key] as List;
    return _decodeList(v, using);
  } on TypeError {
    throw CodableException.wrap(
      CodableException.unexpectedType(expected: 'List', actual: '${_value[key].runtimeType}', data: _value[key]),
      method: 'decode',
      hint: '["$key"]',
    );
  } catch (e, st) {
    Error.throwWithStackTrace(CodableException.wrap(e, method: 'decode', hint: '["$key"]'), st);
  }
}