toDouble method

double? toDouble()

Converts the String value to a double if it's valid.

Returns the double value if the string can be parsed successfully, otherwise returns null.

Example:

String? numberStr = "123.45";
print(numberStr.toDouble()); // 123.45

Implementation

double? toDouble() => isNotEmptyOrNull ? double.tryParse(this!) : null;