RestApiClient class abstract

An abstract class representing a REST API client.

Implementers

Constructors

RestApiClient.new()

Properties

authHandler AuthHandler
getter/setter pair
cacheHandler CacheHandler
getter/setter pair
exceptionHandler ExceptionHandler
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>
no setter
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.
authorize({required String jwt, required String refreshToken}) Future<bool>
Authorizes the client with a JWT and refresh token.
clearStorage() Future
Clears stored credentials and cached data.
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>>
Sends a DELETE request to the specified path.
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 urlPath to savePath.
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>>
Sends a GET request to the specified path.
getCached<T>(String path, {Map<String, dynamic>? queryParameters, FutureOr<T?> onSuccess(dynamic data)?, FutureOr<T> onError(dynamic data)?}) Future<Result<T>>
Gets a cached response from the specified path.
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.
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>>
Streams the result of a GET request to the specified path.
Sends a HEAD request to the specified path.
init() Future<RestApiClient>
Initializes the client and its handlers.
isAuthorized() Future<bool>
Checks if the client is authorized.
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>>
Sends a PATCH request to the specified path.
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>>
Sends a POST request to the specified path.
postCached<T>(String path, {dynamic data, Map<String, dynamic>? queryParameters, FutureOr<T?> onSuccess(dynamic data)?, FutureOr<T> onError(dynamic data)?}) Future<Result<T>>
Gets a cached response from a POST request to the specified path.
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>>
Streams the result of a POST request to the specified path.
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>>
Sends a PUT request to the specified path.
setAcceptLanguageHeader(String languageCode) → void
Sets the Accept-Language header for the requests.
setContentType(String contentType) → void
Sets the content type for the requests.
toString() String
A string representation of this object.
inherited
unAuthorize() Future<bool>
Unauthorizes the client, typically for logging out.

Operators

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

Static Methods

initFlutter() Future<void>
Initializes the Flutter storage repository.