add animation for button "To top"

This commit is contained in:
shirotame 2024-10-06 18:28:28 +04:00
parent 011fbbd05f
commit 28c448046f

View File

@ -155,15 +155,18 @@ class _BodyState extends State<Body> {
], ],
), ),
BlocBuilder<HomeBloc, HomeState>( BlocBuilder<HomeBloc, HomeState>(
builder: (context, state) => state.isButtonToTopShown builder: (context, state) => AnimatedSwitcher(
duration: Duration(milliseconds: 250),
child: state.isButtonToTopShown
? Container( ? Container(
key: ValueKey<int>(1),
alignment: Alignment.topRight, alignment: Alignment.topRight,
padding: EdgeInsets.only(right: 16, top: 64), padding: EdgeInsets.only(right: 16, top: 72),
child: FloatingActionButton( child: FloatingActionButton(
onPressed: _goToTop, onPressed: _goToTop,
child: Icon(Icons.arrow_upward_rounded), child: Icon(Icons.arrow_upward_rounded),
)) ))
: SizedBox.shrink(), : SizedBox.shrink(key: ValueKey<int>(0))),
) )
]); ]);
} }