ApiBase class
Class simplifying Web API calls
- Inheritance
-
- Object
- ChangeNotifier
- ApiBase
- Available Extensions
Constructors
- ApiBase({Client? client, ApiReactions? apiReactions})
- Constructor for ApiBase If a Client isn't provided, the default Client is an http.Client. If a ApiReactions isn't provided, one will be created.
Properties
- accessToken ↔ String?
-
Set the access token
getter/setter pair
- baseUrl ← String
-
Set base URL for Web API calls.
no getter
- cache ↔ ApiCache
-
getter/setter pair
- context → BuildContext?
-
no setter
-
defaultHeaders
→ Map<
String, String> ? -
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- refreshToken ↔ String?
-
Set the refresh token
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addHeaders(
Map< String, String> headers) → void - Add default headers for future HTTP requests
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
delete<
T> (String path, T conversionFunc(dynamic json), {Map< String, String> ? headers, Map<String, dynamic> ? requestBody, Map<String, String> ? queryParameters, Duration? timeoutDuration}) → Future<Either< ApiError, T> > - Perform a DELETE HTTP request
-
deleteHeaders(
List< String> keys) → void - Delete default headers for future HTTP requests
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
inherited
-
get<
T> (String path, T conversionFunc(dynamic json), {Map< String, String> ? headers, Map<String, String> ? queryParameters, Duration? timeoutDuration}) → Future<Either< ApiError, T> > - Perform a GET HTTP request
-
getMimeTypeForFile(
String path) → String -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
patch<
T> (String path, T conversionFunc(dynamic json), {Map< String, String> ? headers, Map<String, dynamic> ? requestBody, Map<String, String> ? queryParameters, Duration? timeoutDuration}) → Future<Either< ApiError, T> > - Perform a PATCH HTTP request
-
post<
T> (String path, T conversionFunc(dynamic json), {Map< String, String> ? headers, Map<String, dynamic> ? requestBody, Map<String, String> ? queryParameters, Duration? timeoutDuration}) → Future<Either< ApiError, T> > - Perform a POST HTTP request
-
put<
T> (String path, T conversionFunc(dynamic json), {Map< String, String> ? headers, Map<String, dynamic> ? requestBody, Map<String, String> ? queryParameters, Duration? timeoutDuration}) → Future<Either< ApiError, T> > - Perform a PUT HTTP request
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
resetHeaders(
) → void - Reset the default headers
-
toString(
) → String -
A string representation of this object.
inherited
-
uploadFile<
T> (String path, T conversionFunc(dynamic json), {required List< File> files, List<String> fieldName = const ["file"], Map<String, String> ? fields, Map<String, String> ? headers, Map<String, dynamic> ? requestBody, Map<String, String> ? queryParameters, Duration? timeoutDuration}) → Future<Either< ApiError, T> >
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
read(
BuildContext context) → ApiBase -
A wrapper around
context.read, it should be used instead of it. -
watch(
BuildContext context) → ApiBase -
A wrapper around
context.watch, it should be used instead of it.