Flutter, remove FAB scaling animation
Actually, when a page is first loaded, the FAB does not animate. But if you remove the FAB (by setting: floatingActionButton: null
) and/or bring it back, it animates. If your business logic permits, maybe use Offstage
or Visibility
widget, to "hide" the FAB instead of removing it. This way, it will disappear and appear instantly.
Another possible solution is, you don't have to use FAB widget, you can pass any widget to floatingActionButton
property, like an IconButton
or whatever, so really, anything is possible. :D
Paem Kacit
Updated on January 01, 2023Comments
-
Paem Kacit over 1 year
When page is loaded at first, FAB always do scaling animation stuff by default.
How to remove/disable Floating Action Button scaling animation
what I have done already is
return Scaffold( floatingActionButtonAnimator: AnimationNoScaling(), ... import 'package:flutter/material.dart'; class AnimationNoScaling extends FloatingActionButtonAnimator{ double? _x; double? _y; @override Offset getOffset({Offset? begin, Offset? end, double? progress}) { _x = begin!.dx +(end!.dx - begin.dx)*progress!; _y = begin.dy +(end.dy - begin.dy)*progress; return Offset(_x!,_y!); } @override Animation<double> getRotationAnimation({Animation<double>? parent}) { return Tween<double>(begin: 1.0, end: 1.0).animate(parent!); } @override Animation<double> getScaleAnimation({Animation<double>? parent}) { return Tween<double>(begin: 1.0, end: 1.0).animate(parent!); } }
and this is not working the above code is also refered from other question
-
AdityaDees over 2 yearsDoes this answer your question? Disable Scaffold FAB animation
-
creativecreatorormaybenot over 2 years@AdityaDees If you look at the code, you will notice the OP actually used the code from that answer.
-
AdityaDees over 2 yearsI think need add more detail, about version of dart and flutter
-
-
Paem Kacit over 2 yearsIt seems that there are prerequisites. There is no animation when loading with the tab bar as the first page. However, if you go to another tab index and then go back to that page, an animation occurs. And I put Container as an argument value instead of FAB. The result was the same.