getSet<T> method

Set<T> getSet<T>()

Reads the ConstantReader instance and returns an object of type Set<T>.

Throws ErrorOf if an instance of Set<T> cannot be constructed.


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