load method
Implementation
@override
Future<bool> load(FileAsset asset, Uint8List? embeddedBytes) async {
// do not load embedded assets.
if (embeddedBytes != null) {
return false;
}
String? assetPath;
String filePath;
switch (asset.runtimeType) {
case AudioAsset:
assert(audioPath != null || path != null,
'''Audio asset not found. Be sure to provide either `audioPath` or `path` in `LocalAssetLoader`.''');
if (audioPath == null && path == null) return false;
filePath = audioPath ?? path!;
break;
case FontAsset:
assert(fontPath != null || path != null,
'''Font asset not found. Be sure to provide either `fontPath` or `path` in `LocalAssetLoader`.''');
if (fontPath == null && path == null) return false;
filePath = fontPath ?? path!;
break;
case ImageAsset:
assert(imagePath != null || path != null,
'''Image asset not found. Be sure to provide either `imagePath` or `path` in `LocalAssetLoader`.''');
if (imagePath == null && path == null) return false;
filePath = imagePath ?? path!;
break;
default:
return false;
}
filePath = filePath.endsWith("/") ? filePath : "$filePath/";
assetPath = filePath + asset.uniqueFilename;
final bytes = await _assetBundle.load(assetPath);
await asset.decode(Uint8List.view(bytes.buffer));
return true;
}