.riv
file should load quickly and managing the RiveFile
yourself is not necessary. But if you intend to use the same .riv
file in multiple parts of your application, or even on the same screen, it might be advantageous to load the file once and keep it in memory.
File
object directly, or use the FileLoader
convenience class with RiveWidgetBuilder
. In both cases, you must call dispose()
on the object when it’s no longer needed to free up memory.File
object across multiple RiveWidget
instances if they use the same .riv
file. This ensures the file is loaded only once and shared in memory.File
is disposed, it cannot be used again. To use the same .riv
file, create a new File
object.File
alive and share it with widgets depends on your state management approach. For global access, load the file in main
or during app startup, and expose it using a package like Provider. If the file is only needed in a specific part of your app, consider loading the file only when required.File.url('YOUR:URL')
. For network assets, cache the file in memory to avoid repeated downloads and unnecessary decoding of the file.