rootAssetLoader function
Creates an asset bundler for a user-defined package.
This allows you to load assets (e.g. templates, partials, config files)
from your own project's lib/
, assets/
, or other accessible folders
using the package's declared name.
packageName
must match the name defined in your pubspec.yaml
.
Example:
final assetLoader = rootAssetLoader('my_app');
final template = await assetLoader.loadAsString('templates/welcome.html');
Throws a AssetLoaderException if the asset cannot be located or loaded.
packageName
: The name of the Dart package to resolve assets from.- Returns a AssetLoaderInterface for loading assets in that package.
Implementation
AssetLoaderInterface rootAssetLoader(String packageName) => AssetLoader.forPackage(packageName);