This repository has been archived by the owner on Feb 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 113
Unhandled Exception: 'package:flutter/src/animation/animation_controller.dart': Failed assertion: line 772 pos 7: '_ticker != null': AnimationController.stop() called after AnimationController.dispose() #72
Open
Comments
错误信息已经很明确了 |
|
一个页面有多个 SVGA 就会这样,希望可以优化 |
可以给一份有问题的 Demo 代码不? |
/// 图片优化封装====================================
class ImagePath {
///svga动画
static Widget loadingSVGA() {
return const SizedBox(
width: 20,
height: 20,
child: SvgaAnimat(file: "assets/svga/abc.svga"),
);
}
///下载图片后缓存图片 cached_network_image
static Widget network(String? imageUrl, {Size? size, BoxFit? fit}) {
return imageUrl != null
? CachedNetworkImage(
imageUrl: imageUrl,
width: size?.width ?? double.infinity,
height: size?.height ?? double.infinity,
fit: fit ?? BoxFit.cover,
placeholder: (context, url) {
return SizedBox(
width: size?.width ?? double.infinity,
height: size?.height ?? double.infinity,
child: loadingSVGA(), //使用 SVGA 在图片加载时有一个 loading 的动画
);
},
errorWidget: (context, url, error) => Container(
color: const Color(0xffF1F8FF),
width: size?.width ?? double.infinity,
height: size?.height ?? double.infinity,
child: const Icon(
Icons.image,
color: Color(0xffD3E2F5),
),
),
)
: Container(
color: const Color(0xffF1F8FF),
width: size?.width ?? double.infinity,
height: size?.height ?? double.infinity,
child: const Icon(
Icons.image,
color: Color(0xffD3E2F5),
),
);
}
}
/// 页面应用 ===================================
List<Widget> _likeList() {
// 猜你喜欢
var tiem = hotProductList!.map((val) {
String pic = Setting.serviceUrl + '/' + val.pic!.replaceAll('\\', '/');
return Column(
children: [
Container(
width: ScreenutilSize().width(120.0),
height: ScreenutilSize().height(120.0),
margin: EdgeInsets.only(right: ScreenutilSize().width(20.0)),
child: ImagePath.network(pic), // 后台读取数据 循环出来就会报错
),
SizedBox(
width: ScreenutilSize().width(120.0),
child: Text(
val.title!,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: ScreenutilSize().fontSize(20),
),
),
),
],
);
});
return tiem.toList();
} |
同样问题 也是多个svga |
无法重现 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
调用动画的时候报这个错不知道怎么解决
The text was updated successfully, but these errors were encountered: