gpt4 book ai didi

flutter - 在收到完整 header 之前关闭连接

转载 作者:IT王子 更新时间:2023-10-29 07:17:03 27 4
gpt4 key购买 nike

我是 Flutter 的新手,我正在开发一个通过 Image.network 显示一长串图像的应用程序。一切都在运行,但非常频繁且绝对随机(即使我滚动得非常慢),我收到此错误:

I/flutter (10990): EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE 
I/flutter (10990): The following HttpException was thrown resolving an image codec:
I/flutter (10990): Connection closed before full header was received, uri =
I/flutter (10990): http://www.attilofficina.altervista.org/phpbackend/JOB/000004/mockup/000004_017.jpg
I/flutter (10990):
I/flutter (10990): When the exception was thrown, this was the stack:
I/flutter (10990): #0 NetworkImage._loadAsync (package:flutter/src/painting/image_provider.dart:525:41)
I/flutter (10990): <asynchronous suspension>.

那些图像被跳过了!

有没有办法处理这个错误并强制重新加载那些丢失的图像?提前特别感谢

我也尝试过使用分页的 listView,一次加载最少的页面数,但这并没有解决,错误总是随机返回。

这里flutter doctor -v

[√] Flutter (Channel stable, v1.7.8+hotfix.3, on Microsoft Windows [Versione 10.0.17134.885], locale it-IT)
• Flutter version 1.7.8+hotfix.3 at C:\src\flutter
• Framework revision b712a172f9 (7 days ago), 2019-07-09 13:14:38 -0700
• Engine revision 54ad777fd2
• Dart version 2.4.0


[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at C:\Users\Mussa.DESKTOP-HFFLS0G\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
• All Android licenses accepted.

[√] Android Studio (version 3.4)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 37.0.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[√] VS Code (version 1.36.0)
• VS Code at C:\Users\Mussa.DESKTOP-HFFLS0G\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.2.0

[√] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android P (API 27) (emulator)

• No issues found!

最佳答案

可能是因为widget在widget树中被重用,从而中断了HTTP请求。然后,您可以在 FutureBuilder 或 Image 小部件中使用 key 。

child: FutureBuilder<File>(
key: ValueKey(imageUrl), // or use UniqueKey()
...

关于flutter - 在收到完整 header 之前关闭连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57058412/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com