toDouble method

double toDouble ()

Parses string and return double value.

Returns null if parsing fails.

Example:

"2.1".toDouble();     // 2.1
"invalid".toDouble(); // null

Implementation

double toDouble() {
  try {
    return double.parse(this);
  } catch (error) {
    return null;
  }
}