loadAsset method

  1. @override
Future<Uint8List> loadAsset(
  1. String path
)
override

Loads an asset as bytes from the given path

The path should be relative to the assets directory Example: 'models/demo.bin' or 'assets/models/demo.bin'

Throws:

  • AssetNotFoundException if asset doesn't exist
  • Exception for other loading errors

Implementation

@override
Future<Uint8List> loadAsset(String path) async {
  try {
    // LargeFileHandler doesn't return bytes, it copies files
    // For the AssetLoader interface, we need to read after copy
    // But this is still memory-intensive for large files
    // Better approach: change AssetSourceHandler to use copyAssetToLocalStorage directly
    throw UnimplementedError(
      'FlutterAssetLoader.loadAsset() is deprecated for large files. '
      'Use copyAssetToFile() instead or call LargeFileHandler directly.'
    );
  } catch (e) {
    throw Exception('Failed to load asset: $path - $e');
  }
}