'Trying to load non-existing image using NetworkImage will crash

This is new in Flutter 3.0, and just on iOS: If I try to loading an image from a URL, which does not exists, using NetworkImage, app will fatally crash, without any reasonable log, this is log :

-[FIRExceptionModel setOnDemand:]: unrecognized selector sent to instance 0x2827854a0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FIRExceptionModel setOnDemand:]: unrecognized selector sent to instance 0x2827854a0'
*** First throw call stack:
(0x1826160fc 0x19ae51d64 0x1826f30c4 0x1825ab524 0x1825aa660 0x10106ba3c 0x10106aeb0 0x104b86fd0 0x104671f6c 0x182286924 0x182288670 0x182296b70 0x1825ced84 0x182588f5c 0x18259c468 0x19e12838c 0x184f3e088 0x184cbc958 0x100fa790c 0x1012ddaa4)
libc++abi: terminating with uncaught exception of type NSException
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001b9021964 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
->  0x1b9021964 <+8>:  b.lo   0x1b9021984               ; <+40>
    0x1b9021968 <+12>: pacibsp 
    0x1b902196c <+16>: stp    x29, x30, [sp, #-0x10]!
    0x1b9021970 <+20>: mov    x29, sp
Target 0: (Runner) stopped.

And there is no way to handle this exception and prevent app from stopping.

I tried CachedNetworkImage, still, app crashes if URL does not exist.



Solution 1:[1]

For this type of execption for loading image, u can use Cached_network_image plugin. in this package you can assign on error msg

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Samu Chakraborty