OLD | NEW |
1 # Resource | 1 # Resource |
2 | 2 |
3 Reading data from package contents and files. | 3 Reading data from package contents and files. |
4 | 4 |
5 A resource is data that can be read into a Dart program at runtime. | 5 A resource is data that can be read into a Dart program at runtime. |
6 A resource is identified by a URI. It can be loaded as bytes or data. | 6 A resource is identified by a URI. It can be loaded as bytes or data. |
7 The resource URI may be a package: URI. | 7 The resource URI may be a package: URI. |
8 | 8 |
9 Example: | 9 Example: |
10 | 10 |
11 ```dart | 11 ```dart |
12 import 'package:resource/resource.dart' show Resource; | 12 import 'package:resource/resource.dart' show Resource; |
13 import 'dart:convert' show UTF8; | 13 import 'dart:convert' show UTF8; |
14 | 14 |
15 main() async { | 15 main() async { |
16 var resource = new Resource("package:foo/foo_data.txt"); | 16 var resource = new Resource("package:foo/foo_data.txt"); |
17 var string = await resource.readAsString(UTF8); | 17 var string = await resource.readAsString(encoding: UTF8); |
18 print(string); | 18 print(string); |
19 } | 19 } |
20 ``` | 20 ``` |
21 | 21 |
22 ## Learning more | 22 ## Learning more |
23 | 23 |
24 Please check out the [API docs](https://www.dartdocs.org/documentation/resource/
latest). | 24 Please check out the [API docs](https://www.dartdocs.org/documentation/resource/
latest). |
25 | 25 |
26 ## Features and bugs | 26 ## Features and bugs |
27 | 27 |
28 Please file feature requests and bugs at the [issue tracker][tracker]. | 28 Please file feature requests and bugs at the [issue tracker][tracker]. |
29 | 29 |
30 [tracker]: https://github.com/dart-lang/resource/issues | 30 [tracker]: https://github.com/dart-lang/resource/issues |
OLD | NEW |