RestProvider class

Retrieves from an HTTP endpoint

Constructors

RestProvider(String baseEndpoint, {required RestModelDictionary modelDictionary, Client? client})

Properties

baseEndpoint String
A fully-qualified URL
final
client ↔ Client
All requests pass through this client.
getter/setter pair
defaultHeaders Map<String, String>?
Headers supplied for every get, delete, and upsert call.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
logger → Logger
final
modelDictionary RestModelDictionary
The glue between app models and generated adapters.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

convertJsonFromGet(String json, String? key) → dynamic
If a key is defined from the adapter and it is not null in the response, use it to narrow the response. Otherwise, if there is only one top level key, use it to narrow the response. Otherwise, return the payload.
delete<_Model extends RestModel>(_Model instance, {Query? query, ModelRepository<RestModel>? repository}) Future<Response?>
Sends a DELETE request method to the endpoint
exists<_Model extends RestModel>({Query? query, ModelRepository<RestModel>? repository}) Future<bool>
Whether a model instance is present. null is returned when existence is unknown. The model instance is not hydrated in the function output; a bool variant (e.g. List<bool>, Map<TModel, bool>) should be returned.
get<_Model extends RestModel>({Query? query, ModelRepository<RestModel>? repository}) Future<List<_Model>>
Query's providerArgs can extend the get functionality:
headersForQuery([Query? query]) Map<String, String>
Expand a query into HTTP headers
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
upsert<_Model extends RestModel>(_Model instance, {Query? query, ModelRepository<RestModel>? repository}) Future<Response?>
Query's providerArgs can extend the upsert functionality:
urlForModel<_Model extends RestModel>(Query? query, [_Model? instance]) String?
Given a model instance and a query, produce a fully-qualified URL

Operators

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

Static Methods

statusCodeIsSuccessful(int? statusCode) bool