parseDouble static method

Double parseDouble(
  1. String str
)

Parses a string to a Double.

str the string to parse

Throws InvalidFormatException if the string cannot be parsed.

Example:

Double a = Double.parseDouble("3.14");
Double b = Double.parseDouble("1.23e-4");

A wrapper class for double that provides Java-like functionality and methods.

This class wraps Dart's primitive double type and provides additional utility methods similar to Java's Double class.

Example usage:

Double a = Double(3.14);
Double b = Double.valueOf(2.71);
Double c = Double.parseDouble("1.618");

print(a.toString()); // "3.14"
print(a.compareTo(b)); // 1 (since 3.14 > 2.71)

Implementation

static Double parseDouble(String str) {
  try {
    return Double(double.parse(str));
  } catch (e) {
    throw InvalidFormatException('Invalid double value: $str');
  }
}