RestApiClientImpl class
- Implemented types
Constructors
-
RestApiClientImpl.new({required RestApiClientOptions options, ExceptionOptions? exceptionOptions, LoggingOptions? loggingOptions, AuthOptions? authOptions, CacheOptions? cacheOptions, List<
Interceptor> interceptors = const []}) - Constructor for initializing the RestApiClientImpl with required options and interceptors.
Properties
- authHandler ↔ AuthHandler
-
Handler for managing authentication
getter/setter pairoverride
- cacheHandler ↔ CacheHandler
-
Handler for managing cache
getter/setter pairoverride
- exceptionHandler ↔ ExceptionHandler
-
Handler for exceptions
getter/setter pairoverride
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
→ Map<
String, String> -
Returns the headers from the Dio instance, converting values to strings.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addOrUpdateHeader(
{required String key, required String value}) → void -
Adds or updates a header in the request.
override
-
Authorizes the user with JWT and refresh token.
override
-
clearStorage(
) → Future -
Clears authentication and cache storage.
override
-
delete<
T> (String path, {dynamic data, Map< String, dynamic> ? queryParameters, FutureOr<T?> onSuccess(dynamic data)?, FutureOr<T> onError(dynamic data)?, RestApiClientRequestOptions? options}) → Future<Result< T> > -
Performs a DELETE request to the specified path with optional data and query parameters.
override
-
download<
T> (String urlPath, dynamic savePath, {dynamic data, Map< String, dynamic> ? queryParameters, RestApiClientRequestOptions? options, ProgressCallback? onReceiveProgress, CancelToken? cancelToken, bool deleteOnError = true, String lengthHeader = Headers.contentLengthHeader, FutureOr<T?> onSuccess(dynamic data)?, FutureOr<T> onError(dynamic data)?}) → Future<Result< T> > -
Downloads a file from the specified URL path to the save path.
override
-
get<
T> (String path, {Map< String, dynamic> ? queryParameters, FutureOr<T?> onSuccess(dynamic data)?, FutureOr<T> onError(dynamic data)?, RestApiClientRequestOptions? options, Duration? cacheLifetimeDuration}) → Future<Result< T> > -
Performs a GET request to the specified path with optional query parameters and callbacks.
override
-
getCached<
T> (String path, {Map< String, dynamic> ? queryParameters, FutureOr<T?> onSuccess(dynamic data)?, FutureOr<T> onError(dynamic data)?}) → Future<Result< T> > -
Performs a cached GET request to the specified path.
override
-
getCachedOrNetwork<
T> (String path, {Map< String, dynamic> ? queryParameters, FutureOr<T?> onSuccess(dynamic data)?, FutureOr<T> onError(dynamic data)?, RestApiClientRequestOptions? options, Duration? cacheLifetimeDuration}) → Future<Result< T> > -
Gets a cached response from the specified
path
or network response if cache miss or expired.override -
getStreamed<
T> (String path, {Map< String, dynamic> ? queryParameters, FutureOr<T?> onSuccess(dynamic data)?, FutureOr<T> onError(dynamic data)?, RestApiClientRequestOptions? options, Duration? cacheLifetimeDuration}) → Stream<Result< T> > -
Performs a streamed GET request to the specified path, optionally using cached data.
override
-
head<
T> (String path, {dynamic data, Map< String, dynamic> ? queryParameters, FutureOr<T?> onSuccess(dynamic data)?, FutureOr<T> onError(dynamic data)?, RestApiClientRequestOptions? options}) → Future<Result< T> > -
Performs a HEAD request to the specified path with optional data and query parameters.
override
-
init(
) → Future< RestApiClient> -
Initializes the client by preparing auth and cache handlers.
override
-
isAuthorized(
) → Future< bool> -
Checks if the user is authorized.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
patch<
T> (String path, {dynamic data, Map< String, dynamic> ? queryParameters, FutureOr<T?> onSuccess(dynamic data)?, FutureOr<T> onError(dynamic data)?, RestApiClientRequestOptions? options}) → Future<Result< T> > -
Performs a PATCH request to the specified path with optional data and query parameters.
override
-
post<
T> (String path, {dynamic data, Map< String, dynamic> ? queryParameters, FutureOr<T?> onSuccess(dynamic data)?, FutureOr<T> onError(dynamic data)?, RestApiClientRequestOptions? options, bool cacheEnabled = false, Duration? cacheLifetimeDuration}) → Future<Result< T> > -
Performs a POST request to the specified path with optional data and query parameters.
override
-
postCached<
T> (String path, {dynamic data, Map< String, dynamic> ? queryParameters, FutureOr<T?> onSuccess(dynamic data)?, FutureOr<T> onError(dynamic data)?}) → Future<Result< T> > -
Performs a cached POST request to the specified path.
override
-
postStreamed<
T> (String path, {dynamic data, Map< String, dynamic> ? queryParameters, FutureOr<T?> onSuccess(dynamic data)?, FutureOr<T> onError(dynamic data)?, RestApiClientRequestOptions? options, Duration? cacheLifetimeDuration}) → Stream<Result< T> > -
Performs a streamed POST request to the specified path, optionally using cached data.
override
-
put<
T> (String path, {dynamic data, Map< String, dynamic> ? queryParameters, FutureOr<T?> onSuccess(dynamic data)?, FutureOr<T> onError(dynamic data)?, RestApiClientRequestOptions? options}) → Future<Result< T> > -
Performs a PUT request to the specified path with optional data and query parameters.
override
-
setAcceptLanguageHeader(
String languageCode) → void -
Sets the Accept-Language header in the request.
override
-
setContentType(
String contentType) → void -
Sets the content type for requests.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
unAuthorize(
) → Future< bool> -
Unauthorizes the user by clearing tokens.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited