OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 import "dart:async" show Future, Stream; |
| 6 import "dart:convert" show Encoding; |
| 7 |
| 8 /// Resource loading strategy. |
| 9 /// |
| 10 /// An abstraction of the functionality needed to load resources. |
| 11 /// |
| 12 /// Implementations of this interface decide which URI schemes they support. |
| 13 abstract class ResourceLoader { |
| 14 /// Reads the file located by [uri] as a stream of bytes. |
| 15 Stream<List<int>> openRead(Uri uri); |
| 16 |
| 17 /// Reads the file located by [uri] as a list of bytes. |
| 18 Future<List<int>> readAsBytes(Uri uri); |
| 19 |
| 20 /// Reads the file located by [uri] as a [String]. |
| 21 /// |
| 22 /// The file bytes are decoded using [encoding], if provided. |
| 23 /// |
| 24 /// If [encoding] is omitted, the default for the `file:` scheme is UTF-8. |
| 25 /// For `http`, `https` and `data` URIs, the Content-Type header's charset |
| 26 /// is used, if available and recognized by [Encoding.getByName], |
| 27 /// otherwise it defaults to Latin-1 for `http` and `https` |
| 28 /// and to ASCII for `data` URIs. |
| 29 Future<String> readAsString(Uri uri, {Encoding encoding}); |
| 30 } |
| 31 |
OLD | NEW |