number method

num number(
  1. String key, {
  2. num defaultValue = 0,
})

Implementation

num number(String key, {num defaultValue = 0}) {
  if (containsKey(key)) {
    if (this[key] is num) {
      return this[key];
    }

    if (this[key] is String) {
      return num.tryParse(this[key]) ?? defaultValue;
    }

    if (this[key] == null) {
      return defaultValue;
    }
  }

  return defaultValue;
}