flutter_advanced_networkimage icon indicating copy to clipboard operation
flutter_advanced_networkimage copied to clipboard

Flutter stable 1.17.x incompatible - exception thrown

Open ninnepinne opened this issue 5 years ago • 3 comments

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!

ninnepinne avatar Jun 02 '20 16:06 ninnepinne

@mchome How confident are you of the master branch's current state? Are there unfinished stuff in there? It seems to work fine. I need to do a release now, with a fix. Not sure if I should release with master (upcoming 0.8.0 state) or a modded 0.7.0. Thanks again.

ninnepinne avatar Jun 03 '20 07:06 ninnepinne

The test cases are passed, and you feel it works good, it should be fine. My http client does not imported by image provider.

mchome avatar Jun 03 '20 09:06 mchome

Ok, thanks.

My http client does not imported by image provider.

Not really sure what you mean...

AdvancedNetworkImage is a subclass of ImageProvider...

This is the change: https://flutter.dev/docs/release/breaking-changes/image-cache-and-provider

And the master branch has these adaptations.

And 0.7.0 is incompatible with 1.17.x stable Flutter if using TransitionToImage (in the way described above).

So a release of 0.8.0 would probably be good thing.

Thanks!

ninnepinne avatar Jun 03 '20 09:06 ninnepinne