diff --git a/example/assets/layout_test.riv b/example/assets/layout_test.riv index edfe8279..bf313680 100644 Binary files a/example/assets/layout_test.riv and b/example/assets/layout_test.riv differ diff --git a/example/lib/examples/responsive_layouts.dart b/example/lib/examples/responsive_layouts.dart index 66654403..466dab9c 100644 --- a/example/lib/examples/responsive_layouts.dart +++ b/example/lib/examples/responsive_layouts.dart @@ -11,6 +11,8 @@ class ExampleResponsiveLayouts extends StatefulWidget { } class _ExampleResponsiveLayoutsState extends State { + 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 { 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()); + } + @override Widget build(BuildContext context) { return RiveWidgetBuilder( fileLoader: fileLoader, + onLoaded: _onLoaded, builder: (context, state) => switch (state) { RiveLoading() => const Center( child: Center(child: CircularProgressIndicator()), @@ -39,7 +47,7 @@ class _ExampleResponsiveLayoutsState extends State { RiveLoaded() => RiveWidget( controller: state.controller, fit: Fit.layout, // pass Fit.layout to use Rive's layout system - // layoutScaleFactor: 1 / 2, // Optionally: scale the layout + layoutScaleFactor: 1 / 2, // Optionally: scale the layout ) }, );