diff --git a/lib/ui/pages/home_page.dart b/lib/ui/pages/home_page.dart index 979e6d1c..6c5105b9 100644 --- a/lib/ui/pages/home_page.dart +++ b/lib/ui/pages/home_page.dart @@ -77,7 +77,6 @@ class _HomePageState extends State with SingleTickerProviderStateMixin @override void dispose() { - _shimmerList.clear(); _recentlyAddedFull.clear(); _recentlyAdded.clear(); _randomTracks.clear(); diff --git a/lib/ui/pages/tracks_page.dart b/lib/ui/pages/tracks_page.dart index 84fcea75..c5c1b77e 100644 --- a/lib/ui/pages/tracks_page.dart +++ b/lib/ui/pages/tracks_page.dart @@ -31,7 +31,7 @@ class _TracksPageState extends State with TickerProviderStateMixin { final _animationKey = 'tracks_page'; final turnsTween = Tween(begin: 0.0, end: 1.0); late final animation = AnimationController(vsync: this, duration: Duration.zero); - AnimationController get animation2 => RefreshLibraryIconController.getController(_animationKey); + AnimationController get animation2 => RefreshLibraryIconController.getController(_animationKey, this); final _minTrigger = 20; @@ -43,9 +43,9 @@ class _TracksPageState extends State with TickerProviderStateMixin { @override void dispose() { + super.dispose(); animation.dispose(); RefreshLibraryIconController.dispose(_animationKey); - super.dispose(); } @override diff --git a/lib/ui/widgets/settings/indexer_settings.dart b/lib/ui/widgets/settings/indexer_settings.dart index 170de2ea..7443b789 100644 --- a/lib/ui/widgets/settings/indexer_settings.dart +++ b/lib/ui/widgets/settings/indexer_settings.dart @@ -839,18 +839,21 @@ Future showRefreshPromptDialog(bool didModifyFolder) async { class RefreshLibraryIconController { static final _controllers = {}; - static AnimationController getController(String key) => _controllers[key]!; + static AnimationController getController(String key, TickerProvider vsync) => _controllers[key] ?? init(key, vsync); - static void init(String key, TickerProvider vsync) { - _controllers[key] ??= AnimationController( + static AnimationController init(String key, TickerProvider vsync) { + _controllers[key]?.dispose(); + final c = AnimationController( duration: const Duration(milliseconds: 1200), vsync: vsync, ); + _controllers[key] = c; + return c; } static void dispose(String key) { - _controllers[key]?.dispose(); - _controllers.remove(key); + final c = _controllers.remove(key); + c?.dispose(); } static void repeat() { @@ -906,7 +909,7 @@ class _RefreshLibraryIconState extends State<_RefreshLibraryIcon> with TickerPro @override Widget build(BuildContext context) { return RotationTransition( - turns: turnsTween.animate(RefreshLibraryIconController.getController(widget.widgetKey)), + turns: turnsTween.animate(RefreshLibraryIconController.getController(widget.widgetKey, this)), child: Icon( Broken.refresh_2, color: context.defaultIconColor(),