parseNum static method

num? parseNum(
  1. Object? value, [
  2. num? def
])

Tries to parse a num.

  • Returns def if value is invalid.

Implementation

static num? parseNum(Object? value, [num? def]) {
  if (value == null) return def;

  if (value is num) {
    return value;
  } else if (value is DateTime) {
    return value.millisecondsSinceEpoch;
  } else {
    var n = _parseNumString(value);
    return n ?? def;
  }
}