tryGet<T> method

T? tryGet<T>(
  1. K key
)

Type-safe typed accessor that returns the value for key if it is of type T, otherwise null.

Implementation

T? tryGet<T>(K key) {
  final value = this[key];
  return value is T ? value : null;
}