dataOrThrow method

T dataOrThrow([
  1. String? message
])

Get the data or throw an exception if data is null.

Useful when you're confident the data should exist.

Example:

final user = response.dataOrThrow();

Implementation

T dataOrThrow([String? message]) {
  if (data == null) {
    throw Exception(message ?? 'Response data is null (status: $statusCode)');
  }
  return data!;
}