I have a FadeInImage.assetNetwork to display picture. I want to handle the exception when the image is not found. According to the documentation, one should use imageErrorBuilder:
A builder function that is called if an error occurs during image loading.
If this builder is not provided, any exceptions will be reported to [FlutterError.onError]. If it is provided, the caller should either handle the exception by providing a replacement widget, or rethrow the exception.
Then I use it like this:
FadeInImage.assetNetwork(
image: myImageUrl,
placeholder: "assets/images/myPlaceholder.gif",
imageErrorBuilder: (context, error, stackTrace) {
return Image.asset("assets/images/loadFailedImage.png",
width: 100, height: 100);
},
)
When my image is not found, loadFailedImage.png is well displayed instead but the exception is not caught, contrary to what the documentation says. How can I handle it to avoid that exception to stay uncaught ?