JSONAPIAdapter<T extends DataModel<T> > mixin
Flutter Data adapter for JSON:API.
Example usage:
@JsonSerializable()
@DataRepository([JSONAPIAdapter, MyJSONAPIAdapter])
class User with DataModel<User> {
@override
final int id;
final String name;
User({this.id, this.name});
}
mixin MyJSONAPIAdapter on RemoteAdapter<User> {
@override
String get baseUrl => "https://my.jsonapi.server/api";
// other customizations
}
- Superclass Constraints
- RemoteAdapter<
T>
- RemoteAdapter<
Properties
-
adapters
→ Map<
String, RemoteAdapter< DataModelMixin> > -
All adapters for the relationship subgraph of
T
and their relationships.no setterinherited - baseUrl → String
-
Returns the base URL for this type
T
.no setterinherited -
defaultHeaders
→ FutureOr<
Map< String, String> > -
A
Map
representing default HTTP headers.no setter -
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 adaptersno setterinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- httpClient → Client
-
An
http.Client
used to make an HTTP request.no setterinherited - internalType → String
-
INTERNAL: DO NOT USE
no setterinherited
- internalWatch ↔ Watcher?
-
ONLY FOR FLUTTER DATA INTERNAL USE
getter/setter pairinherited
- isInitialized → bool
-
no setterinherited
-
localAdapter
→ LocalAdapter<
T> -
finalinherited
-
offlineOperations
→ Set<
OfflineOperation< T> > -
no setterinherited
-
ref
→ Ref<
Object?> -
Give access to the dependency injection system
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- type → String
-
The pluralized and downcased
DataHelpers.getType<T>
version of typeT
by default.no setterinherited
Methods
-
clear(
) → Future< void> -
inherited
-
delete(
Object model, {bool? remote, Map< String, dynamic> ? params, Map<String, String> ? headers, OnSuccessOne<T> ? onSuccess, OnErrorOne<T> ? onError, DataRequestLabel? label}) → Future<T?> -
inherited
-
deleteLocal(
T model, {bool notify = true}) → void -
inherited
-
deserialize(
Object? data, {String? key}) → Future< DeserializedData< T> > - Transforms JSON:API into native format (with included resources)
-
dispose(
) → void -
inherited
-
findAll(
{bool? remote, bool? background, Map< String, dynamic> ? params, Map<String, String> ? headers, bool? syncLocal, OnSuccessAll<T> ? onSuccess, OnErrorAll<T> ? onError, DataRequestLabel? label}) → Future<List< T> > -
inherited
-
findOne(
Object id, {bool? remote, bool? background, Map< String, dynamic> ? params, Map<String, String> ? headers, OnSuccessOne<T> ? onSuccess, OnErrorOne<T> ? onError, DataRequestLabel? label}) → Future<T?> -
inherited
-
initialize(
{bool? remote, required Map< String, RemoteAdapter< adapters, required Ref<DataModelMixin> >Object?> ref}) → Future<RemoteAdapter< T> > -
inherited
-
isOfflineError(
Object? error) → bool -
Determines whether
error
was an offline error.inherited -
keyForModelOrId(
Object model) → String -
inherited
-
log(
DataRequestLabel label, String message, {int logLevel = 1}) → void -
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, DataRequestLabel? label) → FutureOr< R?> -
Implements global request error handling.
inherited
-
onInitialized(
) → Future< void> -
inherited
-
onModelInitialized(
T model) → void -
After model initialization hook
inherited
-
onSuccess<
R> (DataResponse response, DataRequestLabel label) → FutureOr< R?> -
inherited
-
save(
T model, {bool? remote, Map< String, dynamic> ? params, Map<String, String> ? headers, OnSuccessOne<T> ? onSuccess, OnErrorOne<T> ? onError, DataRequestLabel? label}) → Future<T> -
inherited
-
saveLocal(
T model, {bool notify = true}) → T -
inherited
-
sendRequest<
R> (Uri uri, {DataRequestMethod method = DataRequestMethod.GET, Map< String, String> ? headers, Object? body, _OnSuccessGeneric<R> ? onSuccess, _OnErrorGeneric<R> ? onError, bool omitDefaultParams = false, bool returnBytes = false, DataRequestLabel? label, bool closeClientAfterRequest = true}) → Future<R?> -
The function used to perform an HTTP request and return an
R
.inherited -
serialize(
T model, {bool withRelationships = true}) → Future< Map< String, dynamic> > - Transforms native format into JSON:API
-
shouldLoadRemoteAll(
bool remote, Map< String, dynamic> params, Map<String, String> headers) → bool -
Returns whether calling findAll should trigger a remote call.
inherited
-
shouldLoadRemoteOne(
Object? 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 -
watchAllNotifier(
{bool? remote, Map< String, dynamic> ? params, Map<String, String> ? headers, bool? syncLocal, String? finder, DataRequestLabel? label}) → DataStateNotifier<List< T> > -
inherited
-
watchOneNotifier(
String key, {bool? remote, Map< String, dynamic> ? params, Map<String, String> ? headers, AlsoWatch<T> ? alsoWatch, String? finder, DataRequestLabel? label}) → DataStateNotifier<T?> -
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited