Reputation: 729
When I call this function the error occurs.
Image.network(
i.toString(),
errorBuilder:((context, error, stackTrace) =>
const Icon(Icons.account_circle)))
If failed to get image, shows icon instead. But the error below is displayed.
════════ Exception caught by image resource service ════════════════════════════
The following NetworkImageLoadException was thrown resolving an image codec:
HTTP request failed, statusCode: 404, https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Google-flutter-logo.svg/2560px-Google-flutter-logo.svg.png
When the exception was thrown, this was the stack
#0 NetworkImage._loadAsync
package:flutter/…/painting/_network_image_io.dart:97
<asynchronous suspension>
Image provider: NetworkImage("https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Google-flutter-logo.svg/2560px-Google-flutter-logo.svg.png", scale: 1.0)
Image key: NetworkImage("https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Google-flutter-logo.svg/2560px-Google-flutter-logo.svg.png", scale: 1.0)
════════════════════════════════════════════════════════════════════════════════
Why this error occurs even I set errorBuilder
? I tried other URLs but sometimes this error displayed.
Upvotes: 0
Views: 7012
Reputation: 100
I hope this exception is related to http call made by the widget not related to the error widget builder. As we can the error states 404 http status code.
If handling the exception is required you can also try cached image package. below is the link for the package. Package link: https://pub.dev/packages/cached_network_image
Upvotes: 1