datatools 0.5.0
datatools: ^0.5.0 copied to clipboard

A library for Dart to help fetching data from HTTP and file resources and other data sources.

Datatools #

pub package License

Datatools is a library package for Dart and Flutter mobile developers to help fetching data from HTTP and file resources and other data sources.

Key features:

  • Fetch API abstraction (content, control data, exceptions, fetch interface).
  • Fetch API binding to HTTP and HTTPS resources (using http).
  • Fetch API binding to file resources (based on dart:io).
  • Metadata structures to handle links.

This package is at BETA stage, interfaces not fully final yet.

Usage #

Please, see more detailed examples on sample code.

Imports when using Fetch API for HTTP:

import 'package:datatools/fetch_http.dart';

Setting up a HTTP fetcher, fetching JSON, and also handling errors:

  // create a simple fetcher with an endpoint and headers
  final fetcher = HttpFetcher.simple(
          endpoints: [Uri.parse('https://jsonplaceholder.typicode.com/')])
      .headers({'user-agent': 'myapp'});

  // fetch by a relative path, get content as JSON and handle errors
  try {
    final json = await fetcher.fetchJson(Uri(path: 'posts/1'));
    // do something with JSON data...
  } on OriginException catch (e) {
    // handle exceptions ("not found" etc.) issued by origin server
  } catch (e) {
    // handle other exceptions, like caused client code 
  }

Installing #

The package supports Dart null-safety and using it requires at least Dart 2.12 from the stable channel. Please see the official null-safety migration guide.

In the pubspec.yaml of your project add the dependency:

dependencies:
  datatools: ^0.5.0  

All dependencies used by datatools are also ready for null-safety!

Package #

This is a Dart code package named datatools under the geospatial repository.

The package is associated with (but not depending on) the geodata package. The datatools package contains non-geospatial tools to fetch data from HTTP and file resources. The geodata package then provides client-side access for geospatial APIs and data sources.

Libraries #

The package contains following mini-libraries:

LibraryDescription
fetch_apiFetch API abstraction (content, control data, exceptions, fetch interface).
fetch_httpFetch API binding to HTTP and HTTPS resources (using http).
fetch_fileFetch API binding to file resources (based on dart:io).
meta_linkMetadata structures to handle links.

The fetch_file mini library works on all platforms except web. Other libraries should work on all Dart platforms.

For example to access a mini library you should use an import like:

import 'package:datatools/fetch_http.dart';

To use all (expect fetch_file that must be imported separately) libraries of the package:

import 'package:datatools/datatools.dart';

Authors #

This project is authored by Navibyte.

More information and other links are available at the geospatial repository from GitHub.

License #

This project is licensed under the "BSD-3-Clause"-style license.

Please see the LICENSE.

0
likes
130
pub points
36%
popularity

Publisher

navibyte.com

A library for Dart to help fetching data from HTTP and file resources and other data sources.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD (LICENSE)

Dependencies

equatable, http, http_parser, meta, path

More

Packages that depend on datatools