getT<T> method

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

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

Implementation

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