在ListView中使用时发生FadeInImage错误

时间:2020-08-11 12:12:16

标签: android flutter dart

setState() called after dispose(): _ImageState#46191(lifecycle state: defunct, not mounted, stream: ImageStream#75f5c(MultiFrameImageStreamCompleter#f16d5, [250×130] @ 1.0x, 2 listeners), pixels: null, loadingProgress: null, frameNumber: null, wasSynchronouslyLoaded: false)


This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.

The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.
This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose(). >>> #0      State.setState.<anonymous closure> (package:flutter/src/widgets/framework.dart:1197:9)
[√] Flutter (Channel stable, v1.17.5, on Microsoft Windows [Version 10.0.19041.388], locale en-IN)
    • Flutter version 1.17.5 at F:\FlutterProjects\FlutterSdk\flutter
    • Framework revision 8af6b2f038 (6 weeks ago), 2020-06-30 12:53:55 -0700
    • Engine revision ee76268252
    • Dart version 2.8.4


[√] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
    • Android SDK at E:\sdk
    • Platform android-30, build-tools 30.0.0
    • ANDROID_HOME = E:\sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Android Studio (version 4.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 47.1.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[!] IntelliJ IDEA Community Edition (version 2019.2)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.2.3
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

我在ArrayList中有300多张图片。 但是我以20的卡盘加载到ListView

但是,每当我使用某些搜索查询过滤列表时,都会遇到此问题,导致白色背景而不是实际图像。

下面是我的加载图片的代码

Container(
            width: double.infinity,
            child: FadeInImage.assetNetwork(
              placeholder: 'assets/loading_image.png',
              image: Util.getImageUrl(item.business_featured_image),
              height: 130,
              imageErrorBuilder:
                  (BuildContext context, Object y, StackTrace z) {                    
              return Image(
                  image: NetworkImage(
                      Util.getImageUrl(item?.business_featured_image)),
                  fit: BoxFit.cover,
                  height: 130,
                  errorBuilder:
                      (BuildContext context, Object y, StackTrace z) {                       
                    return Center(
                        child: Icon(
                          Icons.broken_image,
                          size: 120,
                          color: colorLightGrey,
                        ));
                  },
                );
              },
              imageCacheHeight: 130,
              imageCacheWidth: 250,
              fit: BoxFit.cover,
            ),
          )

我也在检查挂载和处置属性

if (!_isDispose && mounted) { setState(() { log("setState calling : "); mainList = value; }); _increasePageSize(); }

此错误已经在我的网站上吃了2天,请提供帮助。 过去2年以来,Flutter Github帐户中列出了相同的错误,但仍未修复。

0 个答案:

没有答案