以下网络imageloadexception抛出了图像编解码器:http请求失败,状态代码:404
当我调用此功能时,发生错误。
Image.network(
i.toString(),
errorBuilder:((context, error, stackTrace) =>
const Icon(Icons.account_circle)))
如果无法获得图像,请改为显示图标。但是以下错误显示。
════════ 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)
════════════════════════════════════════════════════════════════════════════════
为什么会发生此错误,即使我设置了errorBuilder
?我尝试了其他URL,但有时会显示此错误。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我希望此例外与小部件与错误窗口小部件构建器无关的http调用有关。
因为我们可以错误状态404 HTTP状态代码。
如果需要处理异常,则还可以尝试缓存的图像包。
以下是包装的链接。
软件包链接: https://pub.dev/packages/cached_network_image_image_image
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