resource 2.1.6

  • Readme
  • Changelog
  • Installing
  • 88

Resource #

Reading data from package contents and files.

A resource is data that can be read into a Dart program at runtime. A resource is identified by a URI. It can be loaded as bytes or data. The resource URI may be a package: URI.


import 'package:resource/resource.dart' show Resource;
import 'dart:convert' show utf8;

main() async {
  var resource = new Resource("package:foo/foo_data.txt");
  var string = await resource.readAsString(encoding: utf8);

Learning more #

Please check out the API docs.

Features and bugs #

Please file feature requests and bugs at the issue tracker.

2.1.6 #

  • Cast stream to List<int> in 'readAsString', this is in preparation for HttpClientResponse implementing Stream<Uint8List> (forward compatible change, should be a no-op for existing usages)

2.1.5 #

  • Require at least Dart 2.0.0-dev.61.

2.1.4 #

  • Require at least Dart 2.0.0.

2.1.3 #

  • Fix bug in readAsBytes which returned twice as much data as expected.

2.1.2 #

  • Fix bug in readAsString when charset is LATIN-1 and content-length is set.

2.1.1 #

  • Reduce max concurrent connections to the same host to 6 when using dart:io. That's the same limit that many browsers use.
  • Trying to load a resource from a non-existing package now gives a better error message.

2.1.0 #

  • Make failing HTTP requests throw an HttpException.

2.0.2 #

  • Update

2.0.1 #

  • Fix type warnings.

2.0.0 #

  • Use configuration dependent imports to avoid having separate implementations for dart:io and dart:html.
  • Remove browser_resource.dart.

1.1.0 #

  • Added browser-compatible version as browser_resource.dart library. Only needed because configurable imports are not available yet.

1.0.0 #

  • Initial version

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  resource: ^2.1.6

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:resource/resource.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Mar 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Fix lib/src/io_io.dart. (-5.84 points)

Analysis of lib/src/io_io.dart reported 12 hints, including:

line 22 col 12: Unnecessary new keyword.

line 35 col 9: Unnecessary new keyword.

line 41 col 12: Unnecessary new keyword.

line 49 col 18: Unnecessary new keyword.

line 58 col 9: Unnecessary new keyword.

Fix lib/src/io_html.dart. (-1.49 points)

Analysis of lib/src/io_html.dart reported 3 hints:

line 23 col 9: Unnecessary new keyword.

line 34 col 9: Unnecessary new keyword.

line 50 col 9: Unnecessary new keyword.

Fix lib/src/io_none.dart. (-1.49 points)

Analysis of lib/src/io_none.dart reported 3 hints:

line 14 col 9: Unnecessary new keyword.

line 22 col 9: Unnecessary new keyword.

line 30 col 9: Unnecessary new keyword.

Fix lib/src/resolve.dart. (-1 points)

Analysis of lib/src/resolve.dart reported 2 hints:

line 13 col 15: Unnecessary new keyword.

line 18 col 10: Unnecessary new keyword.

Fix lib/src/resource_loader.dart. (-0.50 points)

Analysis of lib/src/resource_loader.dart reported 1 hint:

line 34 col 27: Avoid const keyword.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and resource.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.

The package description is too short. (-7 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.61.0 <3.0.0
typed_data ^1.0.0 1.1.6
Dev dependencies
test ^1.0.0