flutter - 按下按钮时播放 Flare 动画
问题描述
我在颤振中创建了一个 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();
},
),
),
解决方案
您必须将 FlareActor 放在 onPressed 方法之外您希望它出现的位置,然后在状态改变时启动它。
以下是有关如何执行此操作的好教程的链接
希望这对您有所帮助。
推荐阅读
- android - 在 build.gradle 中设置变量
- c - 奇怪的右位移不一致
- javascript - 当我清除画布时“canvas.clearRect 不是函数”
- vb.net - 将值从两个条形码扫描仪传递到两个特定的 texbox。
- python-3.x - Selenium Web Scraping Id 缺失
- mysql - 动态确定/创建地理围栏/边界框
- php - 如何使用 laravel 查询 mongodb 以获取与第一个找到的记录和第 N 个数字匹配的记录
- ascii - 关于 ASCII 值
- swift - 无法打开依赖文件 Swift 4.2
- python - TypeError:不支持的操作数类型/:'tuple'和'int'