asset_bundle 1.0.0 copy "asset_bundle: ^1.0.0" to clipboard
asset_bundle: ^1.0.0 copied to clipboard

Bundle multiple assets into one single file.

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();

Create a bundle from multiple files #

  final binary = await AssetBundle.fromFiles([
    File('example/file1.png'),
    File('other.svg'),
  ]);
  final bytes = binaryBundle.asBytes();

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);

Use a generated index #

/// First generate the code containing all the metadata and include the 
// generated code in your project.
print(bundle.toDart('AssetIndex'));
final bundle = AssetBundle.fromBytes(bytes);
final example1 = bundle.load(AssetIndex.e1.id);
final example2 = bundle.load(AssetIndex.e2.id);
0
likes
150
pub points
34%
popularity

Publisher

unverified uploader

Bundle multiple assets into one single file.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

recase

More

Packages that depend on asset_bundle