toDouble method

double? toDouble()

Converts a String todouble if possible.

If conversion fails, null is returned.

Example

String foo = '4';
int fooInt = foo.toDouble(); // returns 4.0;
String foo = '4f';
var fooNull = foo.toDouble(); // returns null;

Implementation

double? toDouble() {
  if (this.isBlank) {
    return null;
  }

  return double.tryParse(this);
}