readAsString method
Returns a Future that completes with the contents of a text asset.
When decoding as text uses encoding
, or utf8 is not specified.
- Throws a
PackageNotFoundException
ifid.package
is not found. - Throws a
AssetNotFoundException
ifid.path
is not found. - Throws an
InvalidInputException
ifid
is an invalid input.
Implementation
@override
Future<String> readAsString(AssetId id, {Encoding encoding = utf8}) async {
if (!await canRead(id)) throw AssetNotFoundException(id);
assetsRead.add(id);
return encoding.decode(assets[id]!);
}