我有一个耀斑加载动画,需要花费一些时间来加载。有没有一种方法可以预缓存抖动动画?
final AssetProvider assetProvider = AssetFlare(bundle: rootBundle, name: 'assets/animations/loop.flr');
cachedActor(assetProvider);
这是缓存参与者的代码吗?然后如何加载缓存的动画?
来自https://github.com/2d-inc/Flare-Flutter/issues/180#issuecomment-550584347您可以使用FlareCacheBuilder
帮助您为应用的某些部分预加载flr文件
代码段
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey,
appBar: AppBar(title: Text(widget.title)),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
child: FlareCacheBuilder(
["assets/Filip.flr"],
builder: (BuildContext context, bool isWarm) {
return !isWarm
? Container(child: Text("Loading..."))
: FlareActor(
"assets/Filip.flr",
alignment: Alignment.center,
fit: BoxFit.contain,
animation: _animationName,
);
},
),
)
],
),
),
);
}