RestApiClient class

Basic implementation of IRestApiClient interface Provides a way to communicate with rest api, manages exceptions that may occure and also manages the authorization logic with jwt and refresh token

Inheritance
Implemented types

Constructors

RestApiClient({required RestApiClientOptions restApiClientOptions, LoggingOptions loggingOptions = const LoggingOptions()})

Properties

exceptionOptions BaseExceptionOptions
Defines options for handling exceptions per request Any direct changes to this instances properties are discarded after the response is handled
getter/setter pairoverride
exceptions StreamController<BaseException>
Provides a way for the user to listen to any RestApiClient exceptions that might happen during the execution of requests
getter/setter pairoverride
hashCode int
The hash code for this object.
no setterinherited
httpClientAdapter HttpClientAdapter
getter/setter pairinherited
interceptors Interceptors
no setterinherited
jwt Future<String>
Get jwt from storage
no setteroverride
loggingOptions LoggingOptions
Customize logging options for requests/responses
final
options BaseOptions
Default Request config. More see BaseOptions.
getter/setter pairinherited
refreshToken Future<String>
Get refresh token from storage
no setteroverride
restApiClientOptions RestApiClientOptions
Use this class to provide configuration for your RestApiClient instance
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
transformer Transformer
transformer allows changes to the request/response data before it is sent/received to/from the server This is only applicable for request methods 'PUT', 'POST', and 'PATCH'.
getter/setter pairinherited

Methods

addAuthorization({required String jwt, required String refreshToken}) Future<bool>
Method that adds Authorization header and initializes mechanism for managing refresh token logic
override
clear() → void
Clear the current Dio instance waiting queue.
inherited
close({bool force = false}) → void
Shuts down the dio client.
inherited
delete<T>(String path, {dynamic data, Map<String, dynamic>? queryParameters, Options? options, CancelToken? cancelToken}) Future<Response<T>>
Handy method to make http DELETE request, which is a alias of BaseDio.requestOptions.
inherited
deleteUri<T>(Uri uri, {dynamic data, Options? options, CancelToken? cancelToken}) Future<Response<T>>
Handy method to make http DELETE request, which is a alias of BaseDio.requestOptions.
inherited
dispose() Future
Best to call this method to set free allocated resources that the RestApiClient instacte might have allocated
override
download(String urlPath, dynamic savePath, {ProgressCallback? onReceiveProgress, Map<String, dynamic>? queryParameters, CancelToken? cancelToken, bool deleteOnError = true, String lengthHeader = Headers.contentLengthHeader, dynamic data, Options? options}) Future<Response>
Download the file and save it in local. The default http method is 'GET', you can custom it by Options.method.
inherited
downloadUri(Uri uri, dynamic savePath, {ProgressCallback? onReceiveProgress, CancelToken? cancelToken, bool deleteOnError = true, String lengthHeader = Headers.contentLengthHeader, dynamic data, Options? options}) Future<Response>
Download the file and save it in local. The default http method is 'GET', you can custom it by Options.method.
inherited
fetch<T>(RequestOptions requestOptions) Future<Response<T>>
inherited
get<T>(String path, {Map<String, dynamic>? queryParameters, Options? options, CancelToken? cancelToken, ProgressCallback? onReceiveProgress}) Future<Response<T>>
Handy method to make http GET request, which is a alias of BaseDio.requestOptions.
inherited
getAndCache<T>(String path, {Map<String, dynamic>? queryParameters, Options? options, CancelToken? cancelToken, ProgressCallback? onReceiveProgress}) Future<Response<T>>
Handy method to make http GET request and cache reponse data
override
getCached<T>(String path, {Map<String, dynamic>? queryParameters, Options? options, CancelToken? cancelToken, ProgressCallback? onReceiveProgress}) Future<Response<T>>
Gets locally saved last response from the path
override
getUri<T>(Uri uri, {Options? options, CancelToken? cancelToken, ProgressCallback? onReceiveProgress}) Future<Response<T>>
Handy method to make http GET request, which is a alias of BaseDio.requestOptions.
inherited
getValidationMessages(DioError error) Map<String, List<String>>
Resolves validation errors from DioError response
Handy method to make http HEAD request, which is a alias of BaseDio.requestOptions.
inherited
headUri<T>(Uri uri, {dynamic data, Options? options, CancelToken? cancelToken}) Future<Response<T>>
Handy method to make http HEAD request, which is a alias of BaseDio.requestOptions.
inherited
init() Future<IRestApiClient>
Method that initializes RestApiClient instance
override
isAuthorized() Future<bool>
Provides information if the current instance of RestApiClient contains Authorization header
override
lock() → void
Lock the current Dio instance.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
patch<T>(String path, {dynamic data, Map<String, dynamic>? queryParameters, Options? options, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) Future<Response<T>>
Handy method to make http PATCH request, which is a alias of BaseDio.requestOptions.
inherited
patchUri<T>(Uri uri, {dynamic data, Options? options, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) Future<Response<T>>
Handy method to make http PATCH request, which is a alias of BaseDio.requestOptions.
inherited
post<T>(String path, {dynamic data, Map<String, dynamic>? queryParameters, Options? options, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) Future<Response<T>>
Handy method to make http POST request, which is a alias of BaseDio.requestOptions.
inherited
postAndCache<T>(String path, {dynamic data, Map<String, dynamic>? queryParameters, Options? options, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) Future<Response<T>>
Handy method to make http POST request and cached response data
override
postCached<T>(String path, {dynamic data, Map<String, dynamic>? queryParameters, Options? options, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) Future<Response<T>>
Gets locally saved last response from the path
override
postUri<T>(Uri uri, {dynamic data, Options? options, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) Future<Response<T>>
Handy method to make http POST request, which is a alias of BaseDio.requestOptions.
inherited
put<T>(String path, {dynamic data, Map<String, dynamic>? queryParameters, Options? options, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) Future<Response<T>>
Handy method to make http PUT request, which is a alias of BaseDio.requestOptions.
inherited
putUri<T>(Uri uri, {dynamic data, Options? options, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) Future<Response<T>>
Handy method to make http PUT request, which is a alias of BaseDio.requestOptions.
inherited
refreshTokenCallback(DioError error) Future
Provides a default implementation for managing the refreshing of the jwt by calling the appropriate api endpoint
removeAuthorization() Future<bool>
Removes authorization header along with jwt and refreshToken from the secure storage
override
request<T>(String path, {dynamic data, Map<String, dynamic>? queryParameters, CancelToken? cancelToken, Options? options, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) Future<Response<T>>
Make http request with options.
inherited
requestUri<T>(Uri uri, {dynamic data, CancelToken? cancelToken, Options? options, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) Future<Response<T>>
Make http request with options.
inherited
setAcceptLanguageHeader(String languageCode) → void
Method that sets appropriate Accept language header
override
toString() String
A string representation of this object.
inherited
unlock() → void
Unlock the current Dio instance.
inherited

Operators

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

Static Methods

initFlutter() Future<void>
Method that should be called as soon as possible