getNum method Null safety

num? getNum(
  1. String key,
  2. [num? defaultValue]
)

Retrieve a value from this map

Implementation

num? getNum(String key, [num? defaultValue]) {
  if (!containsKey(key)) {
    return defaultValue;
  }

  dynamic valueDyn = this[key];

  if (valueDyn is num) {
    return valueDyn;
  }

  if (valueDyn is String) {
    return stringToNum(valueDyn, defaultValue);
  }

  return defaultValue;
}