toDouble static method

double toDouble(
  1. String? s, {
  2. double defaultValue = 0,
})

Implementation

static double toDouble(String? s, {double defaultValue = 0}) {
  if (s == null) return defaultValue;
  try {
    if (s == '' || s == 'null') {
      return defaultValue;
    }
    double d = double.parse(s);
    return d;
  } catch (e) {
    return defaultValue;
  }
}