datatools 0.5.0-nullsafety.0 datatools: ^0.5.0-nullsafety.0 copied to clipboard
A library for Dart to help fetching data from HTTP and file resources and other data sources.
☁️ Datatools #
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 the latest SDK from a beta channel. However your package using it doesn't have to be migrated to null-safety yet.
Please see the official null-safety migration guide how to switch to the latest beta release of Dart or Flutter SDKs.
In the pubspec.yaml
of your project add the dependency:
dependencies:
datatools: ^0.5.0-nullsafety.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:
Library | Description |
---|---|
fetch_api | Fetch API abstraction (content, control data, exceptions, fetch interface). |
fetch_http | Fetch API binding to HTTP and HTTPS resources (using http). |
fetch_file | Fetch API binding to file resources (based on dart:io ). |
meta_link | Metadata 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.