2

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

dontknowhy
  • 2,480
  • 2
  • 23
  • 67

1 Answers1

3

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

WSBT
  • 33,033
  • 18
  • 128
  • 133
  • 1
    It 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. – dontknowhy Oct 25 '21 at 10:30