Flutter stable 1.17.x incompatible - exception thrown #158
Description
Hello (again) and thank you for your work.
Since upgrading to 1.17 stable I have experienced crashes when images failed to load.
Investigated and found out that the reason is the new breaking changes to ImageProvider
in 1.17.
The bug can be reproduced with latest version 0.7.0 by using a TransitionToImage
with a AdvancedNetworkImage
as provider.
If you for example use the plugin to display an image in a list with a builder and the widget is scrolled off and disposed and the image load fails - the result will be an exception.
This error will propagate...
return Future.error(StateError('Failed to load $url.'));
...and if TransitionToImage has been disposed
@override
void dispose() {
_imageStream.removeListener(
ImageStreamListener(_updateImage, onError: _catchBadImage));
_controller.dispose();
super.dispose();
}
No error handlers
_catchBadImage
will be registered and an unhandled error will propagate...
So loading a list of images with flaky network (or failing urls) while scrolling will produce a lot of unhandled exceptions.
I pinned down the solution to the problem to the new error handling in the 1.17.x version of ImageProvider
where even the unhandled, parentless load error is handled by the ImageProvider
(via a safe zone).
I was preparing a pull request from my locally modified flutter_advanced_networkimage.dart
when I discovered that the master branch has already been updated to the 1.17 new version of ImageProvider (the resolve() method removed).
I have tried my app with the master branch version - and no exceptions are thrown
I would very much appreciate a release of 0.8.0 since 0.7.0 is not compatible with the latest stable Flutter release 1.17.x (and it seems like you have already done the work).
Please reach out if there is anything I can do to help.
Thank you!