Flutter_cached_network_image: Unhandled Exception: HttpException: No valid statuscode. Statuscode was 404

Created on 11 Mar 2019  ·  31Comments  ·  Source: Baseflow/flutter_cached_network_image

E/flutter (18499): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: HttpException: No valid statuscode. Statuscode was 404
E/flutter (18499): #0 BaseCacheManager.getFile
package:flutter_cache_manager/src/cache_manager.dart:120
E/flutter (18499):
E/flutter (18499): #1 CachedNetworkImageState._animatedWidget
package:cached_network_image/src/cached_image_widget.dart:261
E/flutter (18499): #2 CachedNetworkImageState.build
package:cached_network_image/src/cached_image_widget.dart:194
E/flutter (18499): #3 StatefulElement.build
package:flutter/…/widgets/framework.dart:3825
E/flutter (18499): #4 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3736
E/flutter (18499): #5 Element.rebuild
package:flutter/…/widgets/framework.dart:3559
E/flutter (18499): #6 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:3716
E/flutter (18499): #7 StatefulElement._firstBuild
package:flutter/…/widgets/framework.dart:3864
E/flutter (18499): #8 ComponentElement.mount
package:flutter/…/widgets/framework.dart:3711
E/flutter (18499): #9 Element.inflateWidget
package:flutter/…/widgets/framework.dart:2956
E/flutter (18499): #10 Element.updateChild
package:flutter/…/widgets/framework.dart:2759
E/flutter (18499): #11 SingleChildRenderObjectElement.mount
package:flutter/…/widgets/framework.dart:4876
E/flutter (18499): #12 Element.inflateWidget
package:flutter/…/widgets/framework.dart:2956
E/flutter (18499): #13 Element.updateChild
package:flutter/…/widgets/framework.dart:2759
E/flutter (18499): #14 SingleChildRenderObjectElement.mount
package:flutter/…/widgets/framework.dart:4876
E/flutter (18499): #15 Element.inflateWidget
package:flutter/…/widgets/framework.dart:2956
E/flutter (18499): #16 Element.updateChild
package:flutter/…/widgets/framework.dart:2759
E/flutter (18499): #17 SingleChildRenderObjectElement.mount
package:flutter/…/widgets/framework.dart:4876
E/flutter (18499): #18 Element.inflateWidget
package:flutter/…/widgets/framework.dart:2956
E/flutter (18499): #19 Element.updateChild
package:flutter/…/widgets/framework.dart:2759
E/flutter (18499): #20 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3747
E/flutter (18499): #21 Element.rebuild
package:flutter/…/widgets/framework.dart:3559
E/flutter (18499): #22 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:3716
E/flutter (18499): #23 ComponentElement.mount
package:flutter/…/widgets/framework.dart:3711
E/flutter (18499): #24 Element.inflateWidget
package:flutter/…/widgets/framework.dart:2956
E/flutter (18499): #25 Element.updateChild
package:flutter/…/widgets/framework.dart:2759
E/flutter (18499): #26 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3747
E/flutter (18499): #27 Element.rebuild
package:flutter/…/widgets/framework.dart:3559
E/flutter (18499): #28 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:3716
E/flutter (18499): #29 ComponentElement.mount
package:flutter/…/widgets/framework.dart:3711
E/flutter (18499): #30 Element.inflateWidget
package:flutter/…/widgets/framework.dart:2956
E/flutter (18499): #31 Element.updateChild
package:flutter/…/widgets/framework.dart:2759
E/flutter (18499): #32 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3747
E/flutter (18499): #33 Element.rebuild
package:flutter/…/widgets/framework.dart:3559
E/flutter (18499): #34 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:3716
E/flutter (18499): #35 ComponentElement.mount
package:flutter/…/widgets/framework.dart:3711
E/flutter (18499): #36 Element.inflateWidget
package:flutter/…/widgets/framework.dart:2956
E/flutter (18499): #37 Element.updateChild
package:flutter/…/widgets/framework.dart:2759
E/flutter (18499): #38 ComponentElement.performRebuild

Most helpful comment

The same problem. It's very strange to throw exceptions when image is not available without ability to catch it. Why just not add callback if any error?

All 31 comments

I have the same error. It only throws this error when I tried to load an image from a url whose response is 404. Is there some way to Catch this exception so that it will not throw an error on the console?

In debug mode it seems to freeze the app.

The same problem. It's very strange to throw exceptions when image is not available without ability to catch it. Why just not add callback if any error?

Emmm. I met the same error which response was 531

I have the same problem when call to a url return 404.

[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: HttpException: No valid statuscode. Statuscode was 404

I've set up with this

errorWidget: (context, url, error) => Icon(Icons.error),

but still, the app crashed when the image is 404.

so what's the point of errorWidget option?

The error comes from visual code debugger (or somewhere around), if you use flutter run from console then all works as it should. It happened to me with my own code and I posted an issue.
https://github.com/flutter/flutter/issues/33427

@cosinus84 I tried running it using flutter run in the console and it still threw this exception. In my code, it's a large list of items with an image for each item. The weird thing is that when they get loaded for the first time no exceptions are thrown, it normally displays the error widget as it should. However, if I start scrolling the list, the exceptions start getting thrown for images with 404 response. I'm not sure what's causing that, but I'll take a look as soon as I'm done with my finals.

#144 #190 might fix this. @basselch, can you test it?

  cached_network_image:
    git:
      url: git://github.com/rmarau/flutter_cached_network_image.git
      ref: fix-getFile_multiplecalls

@rmarau I tested it on my app and your fix works. No exceptions are thrown while scrolling

I have the same problem. Any solution for that?

Fixed in 1.1.0

@renefloor I upgrade to 1.1.0, But got a new error.

[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: type 'HttpException' is not a subtype of type 'FileInfo'    
#0      BaseCacheManager.getFile (package:flutter_cache_manager/src/cache_manager.dart:120:11)                     
<asynchronous suspension>                                                                                          
#1      CachedNetworkImageState._animatedWidget (package:cached_network_image/src/cached_image_widget.dart:270:12) 
#2      CachedNetworkImageState.build (package:cached_network_image/src/cached_image_widget.dart:196:12)           
#3      StatefulElement.build (package:flutter/src/widgets/framework.dart:4012:27)                                 
#4      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3924:15)                       
#5      Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5)                                        
#6      StatefulElement.update (package:flutter/src/widgets/framework.dart:4085:5)                                 
#7      Element.updateChild (package:flutter/src/widgets/framework.dart:2876:15)                                   
#8      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16)                       
#9      Element.rebuild (package:flutter/src/widgets/<…>              

I'm using version 1.1.0 and I still get the console error dump when I recieve a 403 status code when providing an errorWidget.

@renefloor same error.

We are also getting this error, but for 403

I think we're running into https://github.com/flutter/flutter/issues/33427 which seems to be related to a VM problem.

@renefloor

Same question

Same question

我还以为作者回复我了呢。。

Also still have the error with 1.1.1. Only on android tho

i meet the same problem,i found change Icons.error to icons.outlin,it is ok when change back.

same error 1.1.1 fix please

@renefloor facing the same issue in V 1.1.1

Why is this issue closed? Still facing this issue with v1.1.1

If you're using VSCode, then this is probably a false positive from the Dart code plugin. Try and turn off the "Uncaught Exceptions" breakpoint on the debug screen.

Why this happens can be found here: https://github.com/flutter/flutter/issues/33427
It boils down to the crude way in which the dart plugin scans for errors. As I take it, it doesn't use the dart compiler to understand the code, it simply scans your code, and looks for try catch handlers (etc.), and then tries to decide if something is uncaught or not.

Still facing the issue as well

Does some1 know if it is fixed in 1.1.2? I still had it in 1.1.1

Just updated to 1.1.2 and it shows me the error as INFO and not as ERROR:

I/flutter (19879): HttpException: No valid statuscode. Statuscode was 404
I/flutter (19879): CacheManager: Failed to download file from https://............. with error:

Still facing this issue

Same question

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BerndWessels picture BerndWessels  ·  6Comments

tolotrasamuel picture tolotrasamuel  ·  6Comments

anass-naoushi picture anass-naoushi  ·  5Comments

srburton picture srburton  ·  6Comments

digitaldangal picture digitaldangal  ·  5Comments