невозможно выбрать файл из локального хранилища во флаттере - PullRequest
0 голосов
/ 11 июля 2020

Я хочу выбрать файл из локального хранилища, я использую пакет File Picker, но когда я пытаюсь выбрать файл, приложение, к сожалению, закрывается.

String _fileName;
  String _filePath;
  
void _pickFile() async {
    try {
      File _path = (await FilePicker.getFile(
          type: FileType.custom, allowedExtensions: ['jpg', 'pdf', 'doc']));
      if (_path != null) {
        print(_path);
      }
    } on PlatformException catch (e) {
      print(e.toString());
    }
  }

это результат, когда я нажимаю в досье.

 Allowed file extensions mimes: [image/jpeg, application/pdf, application/msword]
D/FilePickerDelegate(28719): Selected type */*
D/FlutterView(28719): Detaching from a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@1fe90ecf
V/ActivityThread(28719): updateVisibility : ActivityRecord{1e11c8eb token=android.os.BinderProxy@197a6cc4 {com.example.dakshata/com.example.dakshata.MainActivity}} show : false
I/FilePickerDelegate(28719): [SingleFilePick] File URI:content://com.android.providers.downloads.documents/document/1623
E/FilePickerUtils(28719): Getting for API 19 or abovecontent://com.android.providers.downloads.documents/document/1623
E/FilePickerUtils(28719): Document URI
E/FilePickerUtils(28719): Downloads External Document URI
E/AndroidRuntime(28719): FATAL EXCEPTION: Thread-7163
E/AndroidRuntime(28719): Process: com.example.dakshata, PID: 28719
E/AndroidRuntime(28719): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
E/AndroidRuntime(28719):        at com.mr.flutter.plugin.filepicker.FilePickerDelegate$2.run(FilePickerDelegate.java:106)
E/AndroidRuntime(28719):        at java.lang.Thread.run(Thread.java:818)
D/mali_winsys(28719): new_window_surface returns 0x3000,  [1440x2560]-format:1
D/FlutterView(28719): Attaching to a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@1fe90ecf
D/mali_winsys(28719): new_window_surface returns 0x3000,  [1440x2560]-format:1
I/Timeline(28719): Timeline: Activity_idle id: android.os.BinderProxy@197a6cc4 time:29054737
I/FilePickerDelegate(28719): Absolute file path:/storage/emulated/0/Download/important-days-and-events-2020-testbook-e5102755.pdf
D/FlutterView(28719): Detaching from a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@1fe90ecf
D/FlutterActivityAndFragmentDelegate(28719): Detaching FlutterEngine from the Activity that owns this Fragment.
D/FlutterEngine(28719): Destroying.
...