diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index 7406bee0..b4b94b8b 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -253,7 +253,7 @@ class ChatListController extends State BoxConstraints? snappingSheetContainerSize; final ScrollController scrollController = ScrollController(); - bool scrolledToTop = true; + final ValueNotifier scrolledToTop = ValueNotifier(true); final StreamController _clientStream = StreamController.broadcast(); @@ -263,10 +263,8 @@ class ChatListController extends State void _onScroll() { final newScrolledToTop = scrollController.position.pixels <= 0; - if (newScrolledToTop != scrolledToTop) { - setState(() { - scrolledToTop = newScrolledToTop; - }); + if (newScrolledToTop != scrolledToTop.value) { + scrolledToTop.value = newScrolledToTop; } } diff --git a/lib/pages/chat_list/start_chat_fab.dart b/lib/pages/chat_list/start_chat_fab.dart index cbeb8f15..5ad7f064 100644 --- a/lib/pages/chat_list/start_chat_fab.dart +++ b/lib/pages/chat_list/start_chat_fab.dart @@ -8,7 +8,7 @@ import 'chat_list.dart'; class StartChatFloatingActionButton extends StatelessWidget { final ActiveFilter activeFilter; - final bool scrolledToTop; + final ValueNotifier scrolledToTop; final bool roomsIsEmpty; const StartChatFloatingActionButton({ @@ -61,27 +61,30 @@ class StartChatFloatingActionButton extends StatelessWidget { @override Widget build(BuildContext context) { - return AnimatedContainer( - duration: FluffyThemes.animationDuration, - curve: FluffyThemes.animationCurve, - width: roomsIsEmpty - ? null - : scrolledToTop - ? 144 - : 56, - child: scrolledToTop - ? FloatingActionButton.extended( - onPressed: () => _onPressed(context), - icon: Icon(icon), - label: Text( - getLabel(context), - overflow: TextOverflow.fade, + return ValueListenableBuilder( + valueListenable: scrolledToTop, + builder: (context, scrolledToTop, _) => AnimatedContainer( + duration: FluffyThemes.animationDuration, + curve: FluffyThemes.animationCurve, + width: roomsIsEmpty + ? null + : scrolledToTop + ? 144 + : 56, + child: scrolledToTop + ? FloatingActionButton.extended( + onPressed: () => _onPressed(context), + icon: Icon(icon), + label: Text( + getLabel(context), + overflow: TextOverflow.fade, + ), + ) + : FloatingActionButton( + onPressed: () => _onPressed(context), + child: Icon(icon), ), - ) - : FloatingActionButton( - onPressed: () => _onPressed(context), - child: Icon(icon), - ), + ), ); } }