-
Notifications
You must be signed in to change notification settings - Fork 222
Update the layouts example #545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,8 @@ class ExampleResponsiveLayouts extends StatefulWidget { | |
| } | ||
|
|
||
| class _ExampleResponsiveLayoutsState extends State<ExampleResponsiveLayouts> { | ||
| late ViewModelInstance viewModelInstance; | ||
|
|
||
| late final fileLoader = FileLoader.fromAsset( | ||
| 'assets/layout_test.riv', | ||
| // Choose which renderer to use | ||
|
|
@@ -21,13 +23,19 @@ class _ExampleResponsiveLayoutsState extends State<ExampleResponsiveLayouts> { | |
| void dispose() { | ||
| // This widget state owns the file loader, dispose it. | ||
| fileLoader.dispose(); | ||
| viewModelInstance.dispose(); | ||
| super.dispose(); | ||
| } | ||
|
|
||
| void _onLoaded(RiveLoaded state) { | ||
| viewModelInstance = state.controller.dataBind(DataBind.auto()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah didn't notice this last time, you can remove this, and instead provide the Then in onLoad, you can do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh because it's a new commit, that's why I didn't notice this :) |
||
| } | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return RiveWidgetBuilder( | ||
| fileLoader: fileLoader, | ||
| onLoaded: _onLoaded, | ||
| builder: (context, state) => switch (state) { | ||
| RiveLoading() => const Center( | ||
| child: Center(child: CircularProgressIndicator()), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use the builder to create the
viewModelInstanceyou also don't need to dispose it here. The builder will dispose.