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<TModel extends RestModel>(TModel instance, {Query? query, ModelRepository<RestModel>? repository}) Future<Response?>
Sends a DELETE request method to the endpoint
exists<TModel 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<TModel extends RestModel>({Query? query, ModelRepository<RestModel>? repository}) Future<List<TModel>>
Query's providerArgs can extend the get functionality:
headersForQuery(Query? query, Map<String, String>? requestHeaders) 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<TModel extends RestModel>(TModel instance, {Query? query, ModelRepository<RestModel>? repository}) Future<Response?>
Query's providerArgs can extend the upsert functionality:

Operators

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

Static Methods

statusCodeIsSuccessful(int? statusCode) bool