无法在“ floatingActionButton”小部件上禁用外观动画

问题描述 投票:0回答:1

Scaffold的floatActionButton属性可以接受任何小部件,因此我在其中使用了一些自定义容器来利用浮动效果。我已经将floatingActionButtonLocation属性设置为“ centerFloat”。问题是,每当我使用此类小部件推送新页面时,它都会使用我要禁用的怪异动画。我发现了这一点:Disable Scaffold FAB animation,所以我扩展了FloatingActionButtonAnimator并尝试了上述示例中显示的内容,但不幸的是,它没有帮助。我很容易处理偏移量。但是旋转和缩放动画仍然存在。即使调整Tween对象的开始和结束值也无济于事。

flutter animation floating-action-button scaffold
1个回答
0
投票

[FloatingActionButton有一个参数herotag,如果您未定义它,它将使用defaultHeroTag,当推送到新页面时,它将检查具有相同名称的herotags并应用动画。

FloatingActionButton(
  heroTag: "MyFirstPage", //give it a custom name to avoid same heroTag in each page
  ...
 )
© www.soinside.com 2019 - 2024. All rights reserved.