I'm new with flutter and I'm working on an app that show a long listView of images via Image.network. All is running, but quite often and absolutely random (even if I scroll very slowly), I get this error:
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>.
And those images are skipped!
Is there a way to handle this error and force reload of those images missing? Special thanks in advance
I've also tried with paginated listView
, with minimum number of pages to be load at a time, but this doesn't solve and the error always returns randomly.
Here 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!
It may be because the widget is reused in the widget tree and thus interrupts the HTTP request. You could then use a key in your FutureBuilder or Image widget.
child: FutureBuilder<File>(
key: ValueKey(imageUrl), // or use UniqueKey()
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With