getDynamic method

dynamic getDynamic()

Reads a constant with type dynamic.

Throws an ErrorOf<ConstantReader> if a constant cannot be constructed.


dynamic getDynamic() {
  final resolvedType = resolveType(dartType);
  if (resolvedType == UnknownType) {
    // Try registered types:
    final types = registeredTypes.difference(resolvedTypes);
    for (final type in types) {
      if (isMatch(dartType, type)) {
        return _decoders[type]!(this);
  } else if (_decoders.containsKey(resolvedType)) {
    return _decoders[resolvedType]!(this);
  throw ErrorOf<ConstantReader>(
      message: 'Could not read constant via get<$dynamic>().',
      expectedState: 'A registered decoder for data-type '
      invalidState: 'Only these types are registered: '