PrimekitNetworkClient class final
A pre-configured Dio HTTP client for Primekit-powered applications.
PrimekitNetworkClient wraps Dio with:
- RetryInterceptor for automatic exponential-backoff retries on 5xx / network errors.
- A structured logging interceptor that records every request/response.
- An optional auth-interceptor slot — supply
onAuthTokento inject a bearer token on every request. - Consistent ApiResponse return types so callers never deal with raw
DioExceptions.
final client = PrimekitNetworkClient(
baseUrl: 'https://api.example.com',
headers: {'X-App-Version': '1.0.0'},
onAuthToken: () async =>
await SecureStorage.instance.read('access_token'),
);
final response = await client.get<User>(
'/users/me',
parser: (json) => User.fromJson(json as Map<String, dynamic>),
);
response.when(
loading: () {}, // never returned by these methods
success: (user) => print(user.name),
failure: (err) => print(err.userMessage),
);
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
delete<
T> (String path, {Object? body, Map< String, Object?> ? queryParameters, T parser(dynamic json)?}) → Future<ApiResponse< T> > -
Performs a DELETE request to
path. -
get<
T> (String path, {Map< String, Object?> ? queryParameters, T parser(dynamic json)?}) → Future<ApiResponse< T> > -
Performs a GET request to
path. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
patch<
T> (String path, {Object? body, Map< String, Object?> ? queryParameters, T parser(dynamic json)?}) → Future<ApiResponse< T> > -
Performs a PATCH request to
pathwith optionalbody. -
post<
T> (String path, {Object? body, Map< String, Object?> ? queryParameters, T parser(dynamic json)?}) → Future<ApiResponse< T> > -
Performs a POST request to
pathwith optionalbody. -
put<
T> (String path, {Object? body, Map< String, Object?> ? queryParameters, T parser(dynamic json)?}) → Future<ApiResponse< T> > -
Performs a PUT request to
pathwith optionalbody. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited