parseDouble static method

double parseDouble(
  1. dynamic val
)

Parses a dynamic value to a double.

If the value is null or cannot be parsed, it returns 0.0. Errors during parsing are caught and printed to the console.

Implementation

static double parseDouble(dynamic val) {
  double value = 0.0;

  try {
    if (val != null) {
      value = double.parse(val.toString());
    }
  } catch (e) {
    print(e);
  }

  return value;
}