as<T> method

T as<T>(
  1. String key
)

Implementation

T as<T>(String key) {
  final value = this[key];
  if (value == null) {
    if (null is T) {
      return null as T;
    }
    throw DartSuiPluginException('Key not found.',
        details: {'key': key, 'data': this});
  }
  try {
    return value as T;
  } on TypeError {
    throw DartSuiPluginException('Incorrect value.', details: {
      'key': key,
      'expected': '$T',
      'value': value.runtimeType,
      'data': this
    });
  }
}