扑动,移除FAB缩放动画



当页面首次加载时,FAB总是默认缩放动画内容。

如何移除/禁用浮动动作按钮缩放动画

我所做的已经是

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!);
}
}

,这是不工作的,上面的代码也从其他问题

引用

实际上,当页面第一次加载时,FAB并没有动画。但是,如果您删除FAB(通过设置:floatingActionButton: null)和/或将其带回来,它会动画。如果您的业务逻辑允许,可以使用OffstageVisibility小部件来"隐藏"。而不是把FAB拆下来。这样,它就会消失,并立即出现。

另一个可能的解决方案是,你不必须使用FAB小部件,你可以传递任何小部件到floatingActionButton属性,如IconButton或其他,所以真的,任何事情都是可能的。: D