Last updated:
0 purchases
asset bundle
asset_bundle #
Bundle multiple assets into one single file.
Usage #
Create a bundle manually #
final bundle = MutableAssetBundle();
bundle.addAsset('example/file1.png', Uint8List.fromList([1, 2, 3]));
bundle.addAsset('other.svg', Uint8List.fromList([4, 5]));
final binary = BinaryAssetBundle.fromBundle(bundle);
final bytes = binaryBundle.asBytes();
copied to clipboard
Create a bundle from multiple files #
final binary = await AssetBundle.fromFiles([
File('example/file1.png'),
File('other.svg'),
]);
final bytes = binaryBundle.asBytes();
copied to clipboard
Read a bundle #
final bundle = AssetBundle.fromBytes(bytes);
final example1 = bundle.load(AssetIndex.e1.id);
final example2 = bundle.load(AssetIndex.e2.id);
final example3 = bundle.load(AssetIndex.e3.id);
copied to clipboard
Use a generated index #
/// First generate the code containing all the metadata and include the
// generated code in your project.
print(bundle.toDart('AssetIndex'));
copied to clipboard
final bundle = AssetBundle.fromBytes(bytes);
final example1 = bundle.load(AssetIndex.e1.id);
final example2 = bundle.load(AssetIndex.e2.id);
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.