ko2ic / image_downloader

Flutter plugin that downloads images and movies on the Internet and saves to Photo Library on iOS or specified directory on Android.
https://pub.dartlang.org/packages/image_downloader#-readme-tab-
MIT License
92 stars 116 forks source link

Detect no internet connection and not-responding URL #16

Closed wonsuyon closed 5 years ago

wonsuyon commented 5 years ago

I've tested on android. and need a detection, timeout for enhancement, thanks.

wonsuyon commented 5 years ago

can't catch 404 the app crashes

ko2ic commented 5 years ago

It can be implemented in your application.

        imageId = await ImageDownloader.downloadImage("https://raw.githubusercontent.com/wiki/ko2ic/image_downloader/images/flutter_no.png").catchError((error) {
          print(error);
        }).timeout(Duration(seconds: 10), onTimeout: () {
          print("timeout");
        });
ko2ic commented 5 years ago

In addition, added error handling in v13.0.2.

wonsuyon commented 5 years ago

Thank you for your quick update. The dart timeout() gives us a good timeout except when the permission dialog appears. and the app doesn't crash. we can catch the error.