From 28c448046f469edd47e956c6419e482da3a9d882 Mon Sep 17 00:00:00 2001 From: shirotame Date: Sun, 6 Oct 2024 18:28:28 +0400 Subject: [PATCH] add animation for button "To top" --- lib/views/home_page/home_page.dart | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/views/home_page/home_page.dart b/lib/views/home_page/home_page.dart index 9cfba7a..3286fa6 100644 --- a/lib/views/home_page/home_page.dart +++ b/lib/views/home_page/home_page.dart @@ -155,15 +155,18 @@ class _BodyState extends State { ], ), BlocBuilder( - builder: (context, state) => state.isButtonToTopShown - ? Container( - alignment: Alignment.topRight, - padding: EdgeInsets.only(right: 16, top: 64), - child: FloatingActionButton( - onPressed: _goToTop, - child: Icon(Icons.arrow_upward_rounded), - )) - : SizedBox.shrink(), + builder: (context, state) => AnimatedSwitcher( + duration: Duration(milliseconds: 250), + child: state.isButtonToTopShown + ? Container( + key: ValueKey(1), + alignment: Alignment.topRight, + padding: EdgeInsets.only(right: 16, top: 72), + child: FloatingActionButton( + onPressed: _goToTop, + child: Icon(Icons.arrow_upward_rounded), + )) + : SizedBox.shrink(key: ValueKey(0))), ) ]); }