AuthResponse<T> class

A generic wrapper for authentication responses.

The AuthResponse class provides a unified way to handle both successful responses and errors, eliminating the need for exceptions in normal flow.

Usage

final response = await authClient.signIn.email(
  email: 'user@example.com',
  password: 'password123',
);

if (response.isSuccess) {
  final session = response.data!;
  print('Signed in: ${session.user.email}');
} else {
  print('Error: ${response.error!.message}');
}

See also:

Constructors

AuthResponse.error(AuthError? error)
Creates an error response.
AuthResponse.success(T? data)
Creates a successful response.

Properties

data → T?
The data returned from the request.
final
error AuthError?
Error if the request failed.
final
hashCode int
The hash code for this object.
no setterinherited
isError bool
Whether the request failed.
no setter
isSuccess bool
Whether the request was successful.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

getOrDefault(T defaultValue) → T?
Unwraps the data, returning the default value if there's an error.
getOrNull() → T?
Unwraps the data, returning null if there's an error.
getOrThrow() → T
Unwraps the data, throwing if there's an error.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited