diff --git a/next_gen_ui_demo/lib/main.dart b/next_gen_ui_demo/lib/main.dart index b39b9e3da..9a6a4f95f 100644 --- a/next_gen_ui_demo/lib/main.dart +++ b/next_gen_ui_demo/lib/main.dart @@ -74,7 +74,17 @@ List< typedef ColorCallback = void Function(Color colorSchemeSeed); class _NextGenAppState extends State { - int step = 0; + int _step = 0; + int get step => _step; + set step(int i) { + _step = switch (i) { + (int a) when a < 0 => 0, + (int a) when a >= steps.length => steps.length - 1, + _ => i, + }; + debugPrint('Step ${step + 1} of ${steps.length}'); + } + Color? colorSchemeSeed; @override @@ -107,8 +117,7 @@ class _NextGenAppState extends State { child: const Icon(Icons.arrow_back), onPressed: () { setState(() { - if (step > 0) step--; - debugPrint('Step = $step'); + step--; }); }, ), @@ -123,8 +132,7 @@ class _NextGenAppState extends State { child: const Icon(Icons.arrow_forward), onPressed: () { setState(() { - if (step + 1 < steps.length) step++; - debugPrint('Step = $step'); + step++; }); }, ), @@ -140,7 +148,6 @@ class _NextGenAppState extends State { onPressed: () { setState(() { step = 0; - debugPrint('Step = $step'); }); }, ), diff --git a/next_gen_ui_demo/lib/title_screen_4c/title_screen_ui.dart b/next_gen_ui_demo/lib/title_screen_4c/title_screen_ui.dart index a08d21e2c..065067ec6 100644 --- a/next_gen_ui_demo/lib/title_screen_4c/title_screen_ui.dart +++ b/next_gen_ui_demo/lib/title_screen_4c/title_screen_ui.dart @@ -255,7 +255,15 @@ class _StartBtnState extends State<_StartBtn> { ), ], ) - .animate(autoPlay: false, onInit: (c) => _btnAnim = c) + .animate( + autoPlay: false, + onInit: (c) { + if (_btnAnim != null && _btnAnim != c) { + _btnAnim?.dispose(); + } + _btnAnim = c; + }, + ) .shimmer(duration: .7.seconds, color: Colors.black), ) .animate() diff --git a/next_gen_ui_demo/lib/title_screen_4d/title_screen_ui.dart b/next_gen_ui_demo/lib/title_screen_4d/title_screen_ui.dart index 5900a6b63..0c9ff9063 100644 --- a/next_gen_ui_demo/lib/title_screen_4d/title_screen_ui.dart +++ b/next_gen_ui_demo/lib/title_screen_4d/title_screen_ui.dart @@ -261,7 +261,15 @@ class _StartBtnState extends State<_StartBtn> { ), ], ) - .animate(autoPlay: false, onInit: (c) => _btnAnim = c) + .animate( + autoPlay: false, + onInit: (c) { + if (_btnAnim != null && _btnAnim != c) { + _btnAnim?.dispose(); + } + _btnAnim = c; + }, + ) .shimmer(duration: .7.seconds, color: Colors.black), ) .animate() diff --git a/next_gen_ui_demo/lib/title_screen_4e/title_screen_ui.dart b/next_gen_ui_demo/lib/title_screen_4e/title_screen_ui.dart index 5900a6b63..0c9ff9063 100644 --- a/next_gen_ui_demo/lib/title_screen_4e/title_screen_ui.dart +++ b/next_gen_ui_demo/lib/title_screen_4e/title_screen_ui.dart @@ -261,7 +261,15 @@ class _StartBtnState extends State<_StartBtn> { ), ], ) - .animate(autoPlay: false, onInit: (c) => _btnAnim = c) + .animate( + autoPlay: false, + onInit: (c) { + if (_btnAnim != null && _btnAnim != c) { + _btnAnim?.dispose(); + } + _btnAnim = c; + }, + ) .shimmer(duration: .7.seconds, color: Colors.black), ) .animate() diff --git a/next_gen_ui_demo/lib/title_screen_5a/title_screen_ui.dart b/next_gen_ui_demo/lib/title_screen_5a/title_screen_ui.dart index 022577f9d..1ed6cf132 100644 --- a/next_gen_ui_demo/lib/title_screen_5a/title_screen_ui.dart +++ b/next_gen_ui_demo/lib/title_screen_5a/title_screen_ui.dart @@ -287,7 +287,15 @@ class _StartBtnState extends State<_StartBtn> { ), ], ) - .animate(autoPlay: false, onInit: (c) => _btnAnim = c) + .animate( + autoPlay: false, + onInit: (c) { + if (_btnAnim != null && _btnAnim != c) { + _btnAnim?.dispose(); + } + _btnAnim = c; + }, + ) .shimmer(duration: .7.seconds, color: Colors.black), ) .animate() diff --git a/next_gen_ui_demo/lib/title_screen_5b/title_screen_ui.dart b/next_gen_ui_demo/lib/title_screen_5b/title_screen_ui.dart index b2f3a4da4..237ad28e0 100644 --- a/next_gen_ui_demo/lib/title_screen_5b/title_screen_ui.dart +++ b/next_gen_ui_demo/lib/title_screen_5b/title_screen_ui.dart @@ -289,7 +289,15 @@ class _StartBtnState extends State<_StartBtn> { ), ], ) - .animate(autoPlay: false, onInit: (c) => _btnAnim = c) + .animate( + autoPlay: false, + onInit: (c) { + if (_btnAnim != null && _btnAnim != c) { + _btnAnim?.dispose(); + } + _btnAnim = c; + }, + ) .shimmer(duration: .7.seconds, color: Colors.black), ) .animate() diff --git a/next_gen_ui_demo/lib/title_screen_6/title_screen_ui.dart b/next_gen_ui_demo/lib/title_screen_6/title_screen_ui.dart index b2f3a4da4..237ad28e0 100644 --- a/next_gen_ui_demo/lib/title_screen_6/title_screen_ui.dart +++ b/next_gen_ui_demo/lib/title_screen_6/title_screen_ui.dart @@ -289,7 +289,15 @@ class _StartBtnState extends State<_StartBtn> { ), ], ) - .animate(autoPlay: false, onInit: (c) => _btnAnim = c) + .animate( + autoPlay: false, + onInit: (c) { + if (_btnAnim != null && _btnAnim != c) { + _btnAnim?.dispose(); + } + _btnAnim = c; + }, + ) .shimmer(duration: .7.seconds, color: Colors.black), ) .animate()