Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

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
zboboan opened this issue Jan 28, 2022 · 7 comments
Assignees

Comments

@zboboan
Copy link

zboboan commented Jan 28, 2022

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: 'package:flutter/src/animation/animation_controller.dart': Failed assertion: line 772 pos 7: '_ticker != null': AnimationController.stop() called after AnimationController.dispose()

调用动画的时候报这个错不知道怎么解决

@PonyCui
Copy link
Member

PonyCui commented Jan 30, 2022

错误信息已经很明确了

@zboboan
Copy link
Author

zboboan commented Jan 30, 2022

错误信息已经很明确了
dispose 后调用了 stop 不知道为什么会这样,试了很多方法都不行

@zboboan
Copy link
Author

zboboan commented Feb 7, 2022

错误信息已经很明确了

一个页面有多个 SVGA 就会这样,希望可以优化

@PonyCui
Copy link
Member

PonyCui commented Feb 8, 2022

可以给一份有问题的 Demo 代码不?

@zboboan
Copy link
Author

zboboan commented Feb 8, 2022

可以给一份有问题的 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();
  }

@sevenvip
Copy link

同样问题 也是多个svga

@PonyCui PonyCui added the bug Something isn't working label Feb 10, 2022
@PonyCui PonyCui self-assigned this Feb 10, 2022
@PonyCui PonyCui removed the bug Something isn't working label Feb 10, 2022
@PonyCui
Copy link
Member

PonyCui commented Feb 10, 2022

无法重现

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants