parseDouble static method
Tries to parse a double.
- Returns
def
ifvalue
is invalid.
Implementation
static double? parseDouble(Object? value, [double? def]) {
if (value == null) return def;
if (value is double) {
return value;
} else if (value is num) {
return value.toDouble();
} else if (value is DateTime) {
return value.millisecondsSinceEpoch.toDouble();
} else {
var n = _parseNumString(value);
return n?.toDouble() ?? def;
}
}