簡體   English   中英

Flutter 文件資源管理器無法使用 file_picker

[英]Flutter file explorer not working with file_picker

抱歉,我是 flutter 的新手。
我創建了一個按鈕,它應該運行以下 function (我想,這也應該打開文件資源管理器)但它不起作用。 Button 在那里,但如果按下它,則不會發生任何事情。


  Padding newPadding() {
    return new Padding(
      padding: const EdgeInsets.only(top: 50.0, bottom: 20.0),
        child: ElevatedButton(
          onPressed:_openFileExplorer,
          child: const Text("Open File picker"),
                ),
              );
  }

FilePickerResult? result = await FilePicker.platform.pickFiles();

    if (result != null) {
      PlatformFile file = result.files.first;
      print(file.path);
    }    
    else {
  // User canceled the picker
  } 
}


我忘記了什么?

file_picker package 需要一些步驟才能在 ios 上正常工作。

請查看以下鏈接中的設置說明:

文件選擇器 ios 設置

在 IOS 中,在 POD 文件中添加以下步驟。

項目 root/ios/Podfile上添加以下行,然后在目標'Runner' do.

Pod::PICKER_MEDIA = false, resp. Pod::PICKER_AUDIO = false, resp. Pod::PICKER_DOCUMENT = false

添加后,代碼應該是這樣的

Pod::PICKER_MEDIA = false, resp. Pod::PICKER_AUDIO = false, resp. Pod::PICKER_DOCUMENT = false
target 'Runner' do
  use_frameworks!
  use_modular_headers!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM