mapValueOfType<T> function

T? mapValueOfType<T>(
  1. dynamic map,
  2. String key
)

Returns a valid T value found at the specified Map key, null otherwise.

Implementation

T? mapValueOfType<T>(dynamic map, String key) {
  final dynamic value = map is Map ? map[key] : null;
  if (T == double && value is int) {
    return value.toDouble() as T;
  }
  return value is T ? value : null;
}