client library

Provides JSON:API client for Flutter, browsers and vm.

There are two clients implementation provided by this library.

The first one, Client, is the most flexible but low level. It operates generic Request and Response objects and performs basic operations such as JSON conversion and error handling. It is agnostic to the document structure and accepts any target URIs.

By default, the DisposableHandler is used which internally creates a new instance of Dart built-in HTTP client for each request and then disposes it. If you want more control of the underlying http client, one option can be to use the PersistentHandler. To use another HTTP client, such as dio implement your own wrapper.

The codec performs JSON encoding/decoding. The default implementation uses native dart:convert. Provide your own PayloadCodec if you need fine-grained control over JSON conversion.

The RoutingClient is a wrapper over Client containing methods representing the most common use cases of resource fetching and manipulation. It can conveniently construct and parse JSON:API documents and URIs. The RoutingClient should be your default choice.

Classes

Client
A basic JSON:API client.
CollectionFetched
DisposableHandler
This HTTP handler creates a new instance of the client for every request and closes the client after the request completes.
HandlerWrapper
A wrapper over the standard Dart HTTP client. It is the developer's responsibility to instantiate the client and call close() on it in the end of the application lifecycle.
MessageConverter
Converts HTTP messages to and from to ones used by the http package.
PersistentHandler
Handler which relies on the built-in Dart HTTP client. It is the developer's responsibility to instantiate the client and call close() on it in the end pf the application lifecycle.
RelatedResourceFetched
A related resource response.
RelationshipFetched<R extends Relationship>
A response to a relationship fetch request.
RelationshipUpdated<R extends Relationship>
A response to a relationship request.
Request
A generic JSON:API request.
ResourceCreated
A response to a new resource creation request. This is always a "201 Created" response.
ResourceFetched
A response to fetch a primary resource request
ResourceUpdated
RoutingClient
A routing JSON:API client

Exceptions / Errors

RequestFailure
Thrown when the server returns a non-successful response.