我是新手,我正在开发一个可通过Image.network显示一长串imageListView的应用程序。 一切都在运行,但是非常频繁且绝对是随机的(即使我滚动得很慢),也会出现此错误:
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
,一次加载的页面数最少,但这无法解决,并且错误总是随机返回。
扑扑医生-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!
答案 0 :(得分:1)
我遇到了完全相同的问题,却始终无法找出问题的原因。 我最终使用了Cached network image库,该库解决了我的图像加载问题。
答案 1 :(得分:1)
可能是因为widget在widget树中被重用,从而中断了HTTP请求。然后,您可以在 FutureBuilder 或 Image 小部件中使用密钥。
trn_it.qm