RemoteAdapter<T extends DataModel<T> > class
An adapter base class for all remote operations for type T
.
Includes:
- Remote methods such as
_RemoteAdapter.findAll
or_RemoteAdapter.save
- Configuration methods and getters like
_RemoteAdapter.baseUrl
or_RemoteAdapter.urlForFindAll
- Serialization methods like
_RemoteAdapterSerialization.serialize
- Watch methods such as
_RemoteAdapterWatch.watchOne
- Access to the
_RemoteAdapter.graph
for subclasses or mixins
This class is meant to be extended via mixing in new adapters. This can be done with the DataRepository annotation on a DataModel class:
@JsonSerializable()
@DataRepository([MyAppAdapter])
class Todo with DataModel<Todo> {
@override
final int id;
final String title;
final bool completed;
Todo({this.id, this.title, this.completed = false});
}
Constructors
-
RemoteAdapter(LocalAdapter<
T> localAdapter)
Properties
-
adapters
↔ Map<
String, RemoteAdapter< DataModel> > -
All adapters for the relationship subgraph of
T
and their relationships.latefinalinherited - baseUrl → String
-
Returns the base URL for this type
T
.no setterinherited -
defaultHeaders
→ FutureOr<
Map< String, String> > -
A
Map
representing default HTTP headers.no setterinherited -
defaultParams
→ FutureOr<
Map< String, dynamic> > -
A
Map
representing default HTTP query parameters. Defaults to empty.no setterinherited - graph → GraphNotifier
-
A GraphNotifier instance also available to adapters
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- httpClient → Client
-
An
http.Client
used to make an HTTP request.no setterinherited - identifierSuffix → String
-
A suffix appended to all BelongsTo relationships in serialized form.
no setterinherited
- internalType → String
-
INTERNAL: DO NOT USE OR ELSE THINGS WILL BREAK
no setterinherited
- isInitialized → bool
-
no setterinherited
-
localAdapter
→ LocalAdapter<
T> -
finalinherited
-
offlineOperations
→ Set<
OfflineOperation< T> > -
no setterinherited
- ref ↔ ProviderReference
-
Give adapter subclasses access to the dependency injection system
latefinalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
throttledGraph
→ DelayedStateNotifier<
List< DataGraphEvent> > -
no setterinherited
- throttleDuration → Duration
-
no setterinherited
- type → String
-
The pluralized and downcased DataHelpers.getType<T> version of type
T
by default.no setterinherited
Methods
-
clear(
) → Future< void> -
inherited
-
delete(
dynamic model, {bool? remote, Map< String, dynamic> ? params, Map<String, String> ? headers, OnData<void> ? onSuccess, OnDataError<void> ? onError}) → Future<void> -
inherited
-
deserialize(
Object? data, {String? key}) → DeserializedData< T, DataModel< DataModel> > -
Returns a DeserializedData object when deserializing a given
data
.inherited -
dispose(
) → void -
inherited
-
fieldForKey(
String key) → String -
Transforms a
key
into a model's field.inherited -
findAll(
{bool? remote, Map< String, dynamic> ? params, Map<String, String> ? headers, bool? syncLocal, bool filterLocal(T)?, OnData<List< ? onSuccess, OnDataError<T> >List< ? onError}) → Future<T> >List< T> > -
inherited
-
findOne(
dynamic model, {bool? remote, Map< String, dynamic> ? params, Map<String, String> ? headers, OnData<T?> ? onSuccess, OnDataError<T?> ? onError}) → Future<T?> -
inherited
-
initialize(
{bool? remote, bool? verbose, required Map< String, RemoteAdapter< adapters, required ProviderReference ref}) → Future<DataModel> >RemoteAdapter< T> > -
inherited
-
initializeModel(
T model, {String? key, bool save = false}) → T -
Initializes
model
making it ready to use with DataModel extensions.inherited -
isNetworkError(
dynamic error) → bool -
Determines whether
error
was a network error.inherited -
keyForField(
String field) → String -
Transforms a model's
field
into a key.inherited -
methodForDelete(
dynamic id, Map< String, dynamic> params) → DataRequestMethod -
Returns HTTP method for delete. Defaults to
DELETE
.inherited -
methodForFindAll(
Map< String, dynamic> params) → DataRequestMethod -
Returns HTTP method for findAll. Defaults to
GET
.inherited -
methodForFindOne(
dynamic id, Map< String, dynamic> params) → DataRequestMethod -
Returns HTTP method for findOne. Defaults to
GET
.inherited -
methodForSave(
dynamic id, Map< String, dynamic> params) → DataRequestMethod -
Returns HTTP method for save. Defaults to
PATCH
ifid
is present, orPOST
otherwise.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onError<
R> (DataException e) → FutureOr< R?> -
Implements global request error handling.
inherited
-
onInitialized(
) → Future< void> -
inherited
-
save(
T model, {bool? remote, Map< String, dynamic> ? params, Map<String, String> ? headers, OnData<T> ? onSuccess, OnDataError<T> ? onError}) → Future<T> -
inherited
-
sendRequest<
R> (Uri uri, {DataRequestMethod method = DataRequestMethod.GET, Map< String, String> ? headers, bool omitDefaultParams = false, DataRequestType requestType = DataRequestType.adhoc, String? key, String? body, OnRawData<R> ? onSuccess, OnDataError<R> ? onError}) → FutureOr<R?> -
The function used to perform an HTTP request and return an
R
.inherited -
serialize(
T model) → Map< String, dynamic> -
Returns a serialized version of a model of
T
, as a Map<String, dynamic> ready to be JSON-encoded.inherited -
shouldLoadRemoteAll(
bool remote, Map< String, dynamic> params, Map<String, String> headers) → bool -
Returns whether calling findAll should trigger a remote call.
inherited
-
shouldLoadRemoteOne(
dynamic id, bool remote, Map< String, dynamic> params, Map<String, String> headers) → bool -
Returns whether calling findOne should initiate an HTTP call.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
urlForDelete(
dynamic id, Map< String, dynamic> params) → String -
Returns URL for delete. Defaults to type/
id
.inherited -
urlForFindAll(
Map< String, dynamic> params) → String -
Returns URL for findAll. Defaults to type.
inherited
-
urlForFindOne(
dynamic id, Map< String, dynamic> params) → String -
Returns URL for findOne. Defaults to type/
id
.inherited -
urlForSave(
dynamic id, Map< String, dynamic> params) → String -
Returns URL for save. Defaults to type/
id
(ifid
is present).inherited -
watchAll(
{bool? remote, Map< String, dynamic> ? params, Map<String, String> ? headers, bool? syncLocal, bool filterLocal(T)?}) → DataStateNotifier<List< T> > -
inherited
-
watchOne(
dynamic model, {bool? remote, Map< String, dynamic> ? params, Map<String, String> ? headers, AlsoWatch<T> ? alsoWatch}) → DataStateNotifier<T?> -
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited