【问题标题】:How to open file picker in flutter?如何在颤动中打开文件选择器?
【发布时间】:2021-06-06 00:39:35
【问题描述】:

请推荐一个支持两个平台的文件选择器 ios 和 android。

https://pub.dev/documentation/file_picker/latest/

我正在使用但无法在 ios 应用中运行的上述 URL 插件,请建议任何新插件。

 FilePickerResult result = await FilePicker.platform.pickFiles(
                        type: FileType.custom,
                        allowedExtensions: ['png', 'cdr', 'psd'],
                      );

                      if(result != null) {
                        files = File(result.files.single.path);

                        setState(() {
                          filePath = files.path;
                          fileName = (filePath.split('/').last);
                          print("File Path Select---" + files.path.toString());
                        });
                      } else {
                        // User canceled the picker
                      }

谢谢

【问题讨论】:

  • 什么不起作用?你读过 iOS 的实现吗?您需要设置一些东西才能工作。
  • 是的,我已阅读并关注,但图像未显示在文件选择器中。
  • 如果你只想选择图片,那么你可以使用 image_picker
  • 添加一些你目前尝试过的代码。
  • 我添加了代码...

标签: android ios flutter


【解决方案1】:

我使用 file_picker:^1.13.3

下一个代码对我来说很好用

File file = await FilePicker.getFile(type: FileType.custom, allowedExtensions: ['jpg', 'jpeg', 'png']);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-07
    • 2022-07-20
    • 2016-06-18
    • 1970-01-01
    • 2021-04-22
    • 2020-05-29
    • 2011-05-24
    • 1970-01-01
    相关资源
    最近更新 更多