datatools library

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


An interface for a resource anchor.
An interface for accessing content body as String, bytes or JSON objects.
Content represents a data entity.
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 interface supporting FetchApi for fetching and Controlled for control data.
Head represents meta data for some content.
An adapter that HttpFetcher instances uses to call http.Client.
HTTP content providing body and stream access for a HTTP response data.
A Fetcher implementation for accessing HTTP or HTTPS resources.
Represents a resource link.
Metadata container for links.


Common failure types related to OriginException.


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


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.


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

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