datatools library Null safety

Fetch API abstraction with binding to HTTP and HTTPS resources.

Usage: import package:datatools/datatools.dart

Exports following mini-libraries at once:

  • package:datatools/base_api.dart
  • package:datatools/fetch_api.dart
  • package:datatools/fetch_http.dart
  • package:datatools/meta_link.dart

However does NOT export the following (that must be imported explicitely):

  • package:datatools/fetch_file.dart

Classes

Anchor
An anchor for a resource.
Body
An interface for accessing content body as String, bytes or JSON objects.
Content
Content represents a data entity.
Controlled<C>
An interface to set control data to a client (ie. HTTP client or fetcher).
FetchApi<C extends Content>
An interface to fetch data from a resource like Web API, a cache or a file.
Fetcher<C extends Content>
A fetcher with FetchApi for fetching and Controlled for control data.
An interface providing meta data for some content.
HttpAdapter
An adapter that HttpFetcher instances uses to call http.Client.
HttpContent
HTTP content providing body and stream access for a HTTP response data.
HttpFetcher
A Fetcher implementation for accessing HTTP or HTTPS resources.
Represents a resource link.
Metadata container for links.

Mixins

FetchMixin<C extends Content>
A mixin for FetchApi with partial implemention.

Functions

fetch(Uri url, {Map<String, String>? headers}) Future<Content>
Fetch (read fully) content body from a HTTP(S) resource identified by url.
fetchBytes(Uri url, {Map<String, String>? headers}) Future<Uint8List>
Fetch content body as bytes from a HTTP(S) resource identified by url.
fetchJson(Uri url, {Map<String, String>? headers, Object? reviver(Object? key, Object? value)?}) Future
Fetch content body as JSON data from a HTTP(S) resource identified by url.
fetchStream(Uri url, {Map<String, String>? headers}) Future<Content>
Fetch content as a stream from a HTTP(S) resource identified by url.
fetchText(Uri url, {Map<String, String>? headers}) Future<String>
Fetch content body as text from a HTTP(S) resource identified by url.

Enums

OriginFailure
Common failure types related to OriginException.

Typedefs

HttpValidator = HttpContent Function(Uri reference, BaseResponse response)
A function to validate a HTTP response, and return HttpContent if success.
UriResolver = Uri Function(Uri reference)
A function to resolve an absolute URI from an URI reference.

Exceptions / Errors

ApiException
An exception occurred when accessing an API.
ClientException
An exception occurred when accessing an API and caused by client-side code.
HttpException
An exception originating from a HTTP response with non-success status code.
OriginException
An exception containing a failure message as a response from an API origin.