getT<T extends Object> method

T? getT<T extends Object>(
  1. String key
)

Get a value inside a map. If it is null this returns null, or another type this throws.

Implementation

T? getT<T extends Object>(String key) {
  final v = this[key];
  if (v == null) {
    return null;
  }
  if (v is! T) {
    throw Exception('Invalid type: ${v.runtimeType} should be $T');
  }
  return v;
}