mobile_api library

Typed REST and GraphQL helpers for Flutter applications.

Import this library to configure API clients, cache authentication tokens, map responses into Result objects, and reuse common request utilities.

Classes

ApiConfig<TokenType extends IBOAuth2Token>
Shared configuration for REST and GraphQL API clients.
AppErrorMessage
BooleanResponse
CacheKey
A strongly typed cache key used by secure storage helpers.
CacheKeyBundle
Helper builders for groups of cache writes.
CacheKeyResolver
Converts supported cache key types into string values.
CheckNetwork
The code you provided is written in Dart and defines a class called CheckNetwork. Here's a breakdown of what each part of the code does:
CoreCacheKey
Built-in reusable (generic) keys.
CursorPage<T>
Cursor paginated GraphQL payload.
CustomFreshLink is a copy of FreshLink
CustomHttpOverrides
CustomJsonDecoder
DynamicCacheKey
User/app-defined dynamic key (allows any custom key).
Failure<S, E extends Exception>
Failed API result containing a typed exception.
GraphqlErrorType
HttpHeadersConst
IBOAuth2Token
OAuth2 token model used by REST and GraphQL refresh flows.
ICacheRepo
Secure key-value cache used by the API clients.
ICacheRepoImpl
Secure-storage-backed implementation of ICacheRepo.
IGraphQl
Contract for GraphQL query helpers supported by the package.
IGraphQlImpl<TokenType extends IBOAuth2Token>
Default GraphQL client implementation with token refresh support.
IHttp
Contract for REST requests supported by the package.
IHttpImpl<TokenType extends IBOAuth2Token>
Default REST client implementation with refresh retry support.
InMemoryCacheRepo
In-memory ICacheRepo for use in tests and temporary sessions.
PageFieldKeys
Configuration for paginated GraphQL container keys.
Result<S, E extends Exception>
Result of a typed API call.
SimpleResult
Lightweight raw response used by simple requests.
Success<S, E extends Exception>
Successful API result containing a decoded value.
SuccessResponse

Mixins

RefreshTokenMixin<TokenType extends IBOAuth2Token>

Typedefs

EmptySuccessBuilder<T> = T Function(int statusCode)
ErrorFromJson<E extends Exception> = E Function(Map<String, dynamic>)
ErrorResponseFactory = IBaseErrorResponse Function()
Creates error response instances from decoded JSON maps.
FromJsonFun<T> = T Function(Map<String, dynamic>)
JsonValueDecoder<T> = T Function(Object? json)
MapParam = Map<String, dynamic>
QueryResponse = QueryResult<Object?>
RefreshBodyBuilder = Map<String, dynamic> Function(String refreshToken)
RefreshTokenFromJson<T extends IBOAuth2Token> = T Function(Map<String, dynamic>)

Exceptions / Errors

DefaultErrorResponse
Default implementation used by the package if caller does not provide one.
ErrorModel
GraphQlErrorModel
IBaseErrorResponse
Public interface that external projects can implement and inject.