bodyAsDateTime method

DateTime bodyAsDateTime()

Converts the response data to a DateTime.

Returns:

  • A DateTime object parsed from the response data.

Implementation

DateTime bodyAsDateTime() {
  if (data is String) {
    return DateTime.tryParse(data) ??
        (throw FormatException("Invalid DateTime: $data"));
  }
  throw FormatException("Cannot convert ${data.runtimeType} to DateTime.");
}