【问题标题】:Play Flare animation on button press按下按钮时播放 Flare 动画
【发布时间】:2020-10-08 10:33:19
【问题描述】:

我在 Flutter 中创建了一个 FloatingActionButton 来共享用户个人资料。每当用户单击该按钮时,我想显示一个小的耀斑动画。我正在使用此代码,但正在显示动画。动画文件为 Congratulations.flr

Tooltip(
                message: "Share with friends",
                child: new FloatingActionButton(
                  heroTag: null,

                  backgroundColor: primaryColor,
                  child: Icon(Icons.share),
                  onPressed: () {

                    FlareActor(
                      'assets/videos/Congratulations.flr',
                      alignment: Alignment.center,
                      fit: BoxFit.contain,
                      animation: 'animate',
                    );
                    shareUserProfile();
                  },
                ),
              ),

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    您必须将 FlareActor 放在 onPressed 方法之外的您希望它出现的位置,然后在状态改变时启动它。

    下面是一个很好的教程链接

    https://medium.com/flutter-community/better-animations-in-flutter-using-flare-an-experiment-bf9fa6c44f13

    希望这对你有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-07
      相关资源
      最近更新 更多