Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- D/permissions_handler(16054): No permissions found in manifest for: $permission
- D/permissions_handler(16054): No permissions found in manifest for: $permission
- I/flutter (16054): decodePermissionRequestResult called with: value:[{14: 4}]
- W/WM-WorkSpec(16054): Backoff delay duration less than minimum value
- E/MethodChannel#vn.hunghd/downloader(16054): Failed to handle method call
- E/MethodChannel#vn.hunghd/downloader(16054): java.lang.IllegalStateException: WorkManager is not initialized properly. The most likely cause is that you disabled WorkManagerInitializer in your manifest but forgot to call WorkManager#initialize in your Application#onCreate or a ContentProvider.
- E/MethodChannel#vn.hunghd/downloader(16054): at androidx.work.WorkManager.getInstance(WorkManager.java:141)
- E/MethodChannel#vn.hunghd/downloader(16054): at vn.hunghd.flutterdownloader.FlutterDownloaderPlugin.enqueue(FlutterDownloaderPlugin.java:175)
- E/MethodChannel#vn.hunghd/downloader(16054): at vn.hunghd.flutterdownloader.FlutterDownloaderPlugin.onMethodCall(FlutterDownloaderPlugin.java:73)
- E/MethodChannel#vn.hunghd/downloader(16054): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:201)
- E/MethodChannel#vn.hunghd/downloader(16054): at io.flutter.view.FlutterNativeView$PlatformMessageHandlerImpl.handleMessageFromDart(FlutterNativeView.java:188)
- E/MethodChannel#vn.hunghd/downloader(16054): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:202)
- E/MethodChannel#vn.hunghd/downloader(16054): at android.os.MessageQueue.nativePollOnce(Native Method)
- E/MethodChannel#vn.hunghd/downloader(16054): at android.os.MessageQueue.next(MessageQueue.java:326)
- E/MethodChannel#vn.hunghd/downloader(16054): at android.os.Looper.loop(Looper.java:160)
- E/MethodChannel#vn.hunghd/downloader(16054): at android.app.ActivityThread.main(ActivityThread.java:6669)
- E/MethodChannel#vn.hunghd/downloader(16054): at java.lang.reflect.Method.invoke(Native Method)
- E/MethodChannel#vn.hunghd/downloader(16054): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
- E/MethodChannel#vn.hunghd/downloader(16054): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
- I/flutter (16054): Download task is failed with reason(WorkManager is not initialized properly. The most likely cause is that you disabled WorkManagerInitializer in your manifest but forgot to call WorkManager#initialize in your Application#onCreate or a ContentProvider.)
- W/5gmail.playlis(16054): Accessing hidden method Ldalvik/system/CloseGuard;->close()V (light greylist, linking)
- import 'package:flutter_downloader/flutter_downloader.dart';
- import 'package:path_provider/path_provider.dart';
- import 'package:permission_handler/permission_handler.dart';
- class DownloadManager {
- Future<bool> checkPermission() async {
- PermissionStatus permission = await PermissionHandler()
- .checkPermissionStatus(PermissionGroup.storage);
- if (permission != PermissionStatus.granted) {
- Map<PermissionGroup, PermissionStatus> permissions =
- await PermissionHandler()
- .requestPermissions([PermissionGroup.storage]);
- if (permissions[PermissionGroup.storage] == PermissionStatus.granted) {
- return true;
- }
- }
- return false;
- }
- void inti(String url) async {
- await checkPermission();
- final directory = await getExternalStorageDirectory();
- final taskId = await FlutterDownloader.enqueue(
- url: url,
- savedDir: directory.toString(),
- showNotification: true, // show download progress in status bar (for Android)
- openFileFromNotification: true, // click on notification to open downloaded file (for Android)
- );
- FlutterDownloader.registerCallback((id, status,progress) {
- print(
- 'Download task ($id) is in status ($status) and process ($progress)');
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement