bodyAsDouble method

double bodyAsDouble()

Converts the response data to a double.

Returns:

  • A double value parsed from the response data.

Implementation

double bodyAsDouble() {
  if (data is num) {
    return data.toDouble();
  }
  if (data is String) {
    return double.tryParse(data) ??
        (throw FormatException("Invalid double: $data"));
  }
  throw FormatException("Cannot convert ${data.runtimeType} to double.");
}