Skip to content

feat(flutter): add assetLoader parameter and .fromBytes constructor to FileLoader#631

Open
zemanux wants to merge 1 commit intorive-app:masterfrom
zemanux:asset-loader
Open

feat(flutter): add assetLoader parameter and .fromBytes constructor to FileLoader#631
zemanux wants to merge 1 commit intorive-app:masterfrom
zemanux:asset-loader

Conversation

@zemanux
Copy link
Copy Markdown

@zemanux zemanux commented Apr 29, 2026

Description

This PR introduces the ability to load Rive files directly from a byte array (Uint8List) by adding a new fromBytes constructor to the FileLoader class. Additionally, it allows developers to pass an optional AssetLoaderCallback (as assetLoader) when loading files from an asset, URL, or directly from bytes, enabling more granular control over custom asset loading.

Motivation and Context

Currently, FileLoader provides quick ways to load a Rive file via an asset or URL, but lacks a direct way to instantiate it natively from raw memory bytes. Furthermore, allowing the injection of an AssetLoaderCallback makes out-of-band assets (like images, fonts, or audio) easier to manage and resolve dynamically at runtime during the file loading stage.

Changes made

  • Added FileLoader.fromBytes(): A new named constructor that takes a Uint8List corresponding to the Rive file's byte data.
  • Added assetLoader parameter: Included an optional AssetLoaderCallback? assetLoader parameter mapped to the fromAsset, fromUrl, and fromBytes constructors.
  • Updated internal file decode routing:
    • Passed assetLoader downwards into rive.File.asset, rive.File.url, and rive.File.decode.
    • Implemented logic in the file() future method to decode _bytes with fallback RiveFileLoaderException error handling if the byte decoding fails.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant