feat(flutter): add assetLoader parameter and .fromBytes constructor to FileLoader#631
Open
zemanux wants to merge 1 commit intorive-app:masterfrom
Open
feat(flutter): add assetLoader parameter and .fromBytes constructor to FileLoader#631zemanux wants to merge 1 commit intorive-app:masterfrom
assetLoader parameter and .fromBytes constructor to FileLoader#631zemanux wants to merge 1 commit intorive-app:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces the ability to load Rive files directly from a byte array (
Uint8List) by adding a newfromBytesconstructor to theFileLoaderclass. Additionally, it allows developers to pass an optionalAssetLoaderCallback(asassetLoader) when loading files from an asset, URL, or directly from bytes, enabling more granular control over custom asset loading.Motivation and Context
Currently,
FileLoaderprovides 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 anAssetLoaderCallbackmakes out-of-band assets (like images, fonts, or audio) easier to manage and resolve dynamically at runtime during the file loading stage.Changes made
FileLoader.fromBytes(): A new named constructor that takes aUint8Listcorresponding to the Rive file's byte data.assetLoaderparameter: Included an optionalAssetLoaderCallback? assetLoaderparameter mapped to thefromAsset,fromUrl, andfromBytesconstructors.assetLoaderdownwards intorive.File.asset,rive.File.url, andrive.File.decode.file()future method to decode_byteswith fallbackRiveFileLoaderExceptionerror handling if the byte decoding fails.Type of change