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(
? Container( duration: Duration(milliseconds: 250),
alignment: Alignment.topRight, child: state.isButtonToTopShown
padding: EdgeInsets.only(right: 16, top: 64), ? Container(
child: FloatingActionButton( key: ValueKey<int>(1),
onPressed: _goToTop, alignment: Alignment.topRight,
child: Icon(Icons.arrow_upward_rounded), padding: EdgeInsets.only(right: 16, top: 72),
)) child: FloatingActionButton(
: SizedBox.shrink(), onPressed: _goToTop,
child: Icon(Icons.arrow_upward_rounded),
))
: SizedBox.shrink(key: ValueKey<int>(0))),
) )
]); ]);
} }