PackageAssetReader class
Resolves using a PackageConfig before reading from the file system.
For a simple implementation that uses the current isolate's package
resolution logic (i.e. whatever you have generated in
.dart_tool/package_config.json in most cases), use currentIsolate:
var assetReader = await PackageAssetReader.currentIsolate();
Doesn't implement AssetReader: for cases that need an AssetReader,
use this class to read the files then write them into a TestReaderWriter.
To copy all the sources see TestReaderWriter.testing.loadIsolateSources.
Constructors
- PackageAssetReader(PackageConfig packageConfig, [String? _rootPackage])
-
Wrap a
PackageConfigto identify where files are located. - PackageAssetReader.forPackageRoot(String packageRoot, [String? rootPackage])
-
A PackageAssetReader with a single
packageRootconfigured.factory -
PackageAssetReader.forPackages(Map<
String, String> packageToPath, [String? rootPackage]) -
Returns a PackageAssetReader with a simple
packageToPathmapping.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- packageConfig → PackageConfig
-
The package config.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
canRead(
AssetId id) → Future< bool> -
findAssets(
Glob glob, {String? package}) → Stream< AssetId> -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
readAsBytes(
AssetId id) → Future< List< int> > -
readAsString(
AssetId id, {Encoding encoding = utf8}) → Future< String> -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
currentIsolate(
{String? rootPackage}) → Future< PackageAssetReader> - A reader that can resolve files known to the current isolate.