DfApiClient class
Centralized HTTP API client used for all network calls.
DfApiClient wraps the http package and provides:
- Unified GET/POST/PUT/PATCH/DELETE methods
- Automatic retry logic
- Token refresh handling
- Network connectivity checks
- Timeout handling
- Firebase Crashlytics error reporting
All requests are executed using configuration provided by DfHttpClientConfig.
Constructors
-
DfApiClient({required DfHttpClientConfig httpApiConfig, Client? client, Future<
void> onErrorRecorded(Object error, StackTrace? stack)?}) - Creates a new API client with the given HTTP configuration.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- httpApiConfig → DfHttpClientConfig
-
HTTP configuration used for all API calls.
final
- httpClient → Client
-
final
-
onErrorRecorded
→ Future<
void> Function(Object error, StackTrace? stack)? -
Add a callback for recording errors to avoid Firebase dependency in tests
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
copyWith(
{DfHttpClientConfig? httpApiConfig}) → DfApiClient - Use DfApiClient constructor instead.
-
delete(
String apiPath, {Object? body, bool jsonEncodeBody = true}) → Future< Response?> -
Executes a HTTP DELETE request for the given
apiPath. -
dispose(
) → void - Close underlying resources used by this client. Call this when the client is no longer needed.
-
get(
String apiPath) → Future< Response?> -
Executes a HTTP GET request for the given
apiPath. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
patch(
String apiPath, {Object? body, bool jsonEncodeBody = true}) → Future< Response?> -
Executes a HTTP PATCH request for the given
apiPath. -
post(
String apiPath, {Object? body, bool jsonEncodeBody = true}) → Future< Response?> -
Executes a HTTP POST request for the given
apiPath. -
put(
String apiPath, {Object? body, bool jsonEncodeBody = true}) → Future< Response?> -
Executes a HTTP PUT request for the given
apiPath. -
toString(
) → String -
A string representation of this object.
inherited
-
tryRecordException(
{required Exception exception, StackTrace? stack}) → Future< void> - Attempts to log an exception to an external monitoring service.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
-
onConnectivityChanged
→ Stream<
bool> -
no setter