OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// A [Resource] is data that can be loaded into a Dart program. | 5 /// A [Resource] is data that can be read into a Dart program. |
6 /// | 6 /// |
7 /// A resource is identified by a URI. | 7 /// A resource is identified by a URI. It can be loaded as bytes or data. |
| 8 /// The resource URI may be a `package:` URI. |
| 9 /// |
| 10 /// Example: |
| 11 /// |
| 12 /// var resource = new Resource("package:foo/foo_data.txt"); |
| 13 /// var string = await resource.readAsString(UTF8); |
| 14 /// print(string); |
| 15 /// |
| 16 /// Example: |
| 17 /// |
| 18 /// var resource = new Resource("http://example.com/data.json"); |
| 19 /// var obj = await resource.openRead() // Reads as stream of bytes. |
| 20 /// .transform(UTF8.fuse(JSON).decoder) |
| 21 /// .first; |
| 22 /// |
| 23 /// |
| 24 /// Notice: Currently this package requires `dart:io` to do the reading, |
| 25 /// so it doesn't work in the browser. |
8 library resource; | 26 library resource; |
9 | 27 |
10 export "src/resource.dart" show Resource; | 28 export "src/resource.dart" show Resource; |
11 export "src/loader.dart" show ResourceLoader; | 29 export "src/loader.dart" show ResourceLoader; |
OLD | NEW |