Flutter下载文件,flutter_downloader中的问题‘Backoff delay duration less than minimum value’

flutter_downloader这个插件在用的时候,Android模拟器上面会出现下面这个报错,进度一直是0
Backoff delay duration less than minimum value

  • 看了很多issue,发现一个issue戳中要害

https://github.com/fluttercommunity/flutter_downloader/issues/105
模拟器上面的WiFi或者信号中有个x号,因为无法访问到google,则判断网络无法连接,导致无法下载,实际上是可以连接网络的。

// 源码在flutter_downloader/android/src/main/java/vn/hunghd/flutterdownloader/FlutterDownloaderPlugin.java 143行、
...
private WorkRequest buildRequest(String url, String savedDir, String filename, String headers, boolean showNotification, boolean openFileFromNotification, boolean isResume, boolean requiresStorageNotLow) {
        WorkRequest request = new OneTimeWorkRequest.Builder(DownloadWorker.class)
                .setConstraints(new Constraints.Builder()
                        .setRequiresStorageNotLow(requiresStorageNotLow)
                        .setRequiredNetworkType(NetworkType.CONNECTED) // 这里
                        .build())
                .addTag(TAG)
                .setBackoffCriteria(BackoffPolicy.EXPONENTIAL, 5, TimeUnit.SECONDS)
                .setInputData(new Data.Builder()
                        .putString(DownloadWorker.ARG_URL, url)
                        .putString(DownloadWorker.ARG_SAVED_DIR, savedDir)
                        .putString(DownloadWorker.ARG_FILE_NAME, filename)
                        .putString(DownloadWorker.ARG_HEADERS, headers)
                        .putBoolean(DownloadWorker.ARG_SHOW_NOTIFICATION, showNotification)
                        .putBoolean(DownloadWorker.ARG_OPEN_FILE_FROM_NOTIFICATION, openFileFromNotification)
                        .putBoolean(DownloadWorker.ARG_IS_RESUME, isResume)
                        .build()
                )
                .build();
        return request;
...
  • 解决方案

https://hky.moe/archives/162/

这个issue里面大哥的方案
https://github.com/fluttercommunity/flutter_downloader/issues/105#issuecomment-650579300

你可能感兴趣的:(Flutter下载文件,flutter_downloader中的问题‘Backoff delay duration less than minimum value’)