toDouble static method
Tries to parse value into double.
null, int, double, bool, String.
If none found, then 'null' is returned.
Implementation
static double? toDouble(dynamic value) {
if (value is double) {
return value;
}
if (value == null) {
return null;
}
if (value is int) {
return value.toDouble();
}
if (value is bool) {
return value ? 1.0 : 0.0;
}
if (value is String) {
return double.tryParse(value.replaceAll(',', '.'));
}
return null;
}