craft library

Simple and intuitive HTTP clients (crafts) that support OAuth token auto-refresh, queueing and serialization of requests, storing requests locally for offline support ...

Classes

AutoRefreshingBearerOauthCraft
RefreshableBearerOauthCraft with ability to automatically refresh accessToken and refreshToken using refreshTokens method from AutoRefreshing.
AutoRefreshingTokenOauthCraft
RefreshableTokenOauthCraft with ability to automatically refresh accessToken and refreshToken using refreshTokens method from AutoRefreshing.
BaseCraft
Base class for sending Requests. It only wraps the methods exposed in http package.
BearerOauthCraft
OauthCraft that uses "Bearer accessToken" as Authorization header.
Craft<T extends BaseCraft>
A Craft is an HTTP client. It can be just a basic client, but is meant to be used as an enhanced feature-rich client that provides commonly used abilities - such as OAuth token auto-refresh, persisting token in a secure storage and automatically retrieving it when being created, queueing of the HTTP requests - out of the box.
OauthCraft
Craft implementing the OAuth flow. It has an accessToken which can be a regular token, a bearer token, or a custom one by defining a custom craft extending the OauthCraft.
PersistableAutoRefreshingBearerOauthCraft
AutoRefreshingBearerOauthCraft that persists refresh token using RefreshTokenPersistable.
PersistableAutoRefreshingTokenOauthCraft
AutoRefreshingTokenOauthCraft that persists refresh token using RefreshTokenPersistable.
PersistableBearerOauthCraft
TokenOauthCraft that persists access token using AccessTokenPersistable.
PersistableRefreshableBearerOauthCraft
RefreshableBearerOauthCraft that persists refresh token using RefreshTokenPersistable.
PersistableRefreshableTokenOauthCraft
RefreshableTokenOauthCraft that persists refresh token using RefreshTokenPersistable.
PersistableTokenOauthCraft
TokenOauthCraft that persists access token using AccessTokenPersistable.
QAutoRefreshingBearerOauthCraft
An AutoRefreshingBearerOauthCraft with ability of queueing requests using RequestQueueing.
QAutoRefreshingTokenOauthCraft
An AutoRefreshingTokenOauthCraft with ability of queueing requests using RequestQueueing.
QBaseCraft
A BaseCraft with ability of queueing requests using RequestQueueing.
QBearerOauthCraft
A BearerOauthCraft with ability of queueing requests using RequestQueueing.
QPersistableAutoRefreshingBearerOauthCraft
A PersistableAutoRefreshingBearerOauthCraft with ability of queueing requests using RequestQueueing.
QPersistableAutoRefreshingTokenOauthCraft
A PersistableAutoRefreshingTokenOauthCraft with ability of queueing requests using RequestQueueing.
QPersistableBearerOauthCraft
A PersistableBearerOauthCraft with ability of queueing requests using RequestQueueing.
QPersistableRefreshableBearerOauthCraft
A PersistableRefreshableBearerOauthCraft with ability of queueing requests using RequestQueueing.
QPersistableRefreshableTokenOauthCraft
A PersistableRefreshableTokenOauthCraft with ability of queueing requests using RequestQueueing.
QPersistableTokenOauthCraft
A PersistableTokenOauthCraft with ability of queueing requests using RequestQueueing.
QRefreshableBearerOauthCraft
A RefreshableBearerOauthCraft with ability of queueing requests using RequestQueueing.
QRefreshableTokenOauthCraft
A RefreshableTokenOauthCraft with ability of queueing requests using RequestQueueing.
QTokenOauthCraft
A TokenOauthCraft with ability of queueing requests using RequestQueueing.
RefreshableBearerOauthCraft
BearerOauthCraft with ability to refresh accessToken using refreshTokens method from Refreshable.
RefreshableTokenOauthCraft
TokenOauthCraft with ability to refresh accessToken using refreshTokens method from Refreshable.
Request<T>
A base request class providing information about an HTTP request.
Serializable
Every Request body must inherit from Serializable in order to be able to convert it toJson for sending the request and for storing it locally.
TokenOauthCraft
OauthCraft that uses "Token accessToken" as Authorization header.
TokenPair
A pair of access and refresh tokens used for OAuth2 authentication.

Enums

HttpMethod
An enum for HTTP methods.

Mixins

AccessTokenPersistable
Extends Persistable functionality to save accessToken.
AutoRefreshing
Provides functionality for automatically refreshing _accessToken after Duration obtained from _accessToken using _tokenExpiration method.
Persistable
Provides functionality for storing a single token in a (secure) storage. By default, the storage used is FlutterSecureStorage but any solution implementing TokenStorage can be used.
Refreshable
Provides functionality for refreshing the accessToken using refreshToken and given refresh token method.
RefreshTokenPersistable
Extends Persistable functionality to save refreshToken.
RequestQueueing
Provides support for executing requests sequentially. This is useful if the order of the requests sent to the server is important and the next request should only be sent once the first one completes. Of course, this has performance implications in the means of longer completion time of multiple requests.

Typedefs

Json = Map<String, dynamic>
Convenience definition of json.

Exceptions / Errors

PersistableAutoPromotionError
Error denoting failed promotion to a Persistable variant at craft brewing.