getList<T> method

List<T> getList<T>()

Reads the ConstantReader instance and returns an instance of List<T>.

Throws ErrorOf if an instance of List<T> can not be constructed.


List<T> getList<T>() {
  if (!holdsA<List<T>>()) {
    throw ErrorOf<ConstantReader>(
        message: 'Input does not represent an object of type <List<$T>',
        invalidState: 'Input represents an object of type '
  if (!_decoders.containsKey(T) && T != dynamic) {
    throw ErrorOf<ConstantReader>(
        message: 'Could not read list-entry value of type [$T].',
        invalidState: 'A decoder function for type [$T] is missing.',
        expectedState: 'Use addDecoder<$T>() to register a decoder '
            'function for type [$T].');
  return => ConstantReader(item).get<T>()).toList();