Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 颤振文件\u选择器包为所有文件详细信息提供空值_Flutter - Fatal编程技术网

Flutter 颤振文件\u选择器包为所有文件详细信息提供空值

Flutter 颤振文件\u选择器包为所有文件详细信息提供空值,flutter,Flutter,我从file_picker package docs复制了相同的代码,但它始终为所有文件详细信息提供空值,以下是我复制的代码 FilePickerResult result = await FilePicker.platform.pickFiles(); if(result != null) { PlatformFile file = result.files.first; print(file.name); print(file.bytes); print(f

我从file_picker package docs复制了相同的代码,但它始终为所有文件详细信息提供空值,以下是我复制的代码

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

if(result != null) {
   PlatformFile file = result.files.first;
   
   print(file.name);
   print(file.bytes);
   print(file.size);
   print(file.extension);
   print(file.path);
}
文件名、字节、大小、扩展名和路径都提供空值。有人知道这是什么原因吗?
我已尝试上载pdf、png、jpg和doc,并为所有这些文件获取相同的空值。

我正在使用此文件的最新版本:


我尝试了你的代码,但它甚至没有打开文件pickerStrange,在这里工作得很好_pickingType应为FileType.Any如果您可以添加完整的方法,请将完整的dart文件发送给我,但文件资源管理器仍无法打开
  void _openFileExplorer() async {
      File _pickedFile;
      FilePickerResult _filePickerResult;
      setState(() {
        _isLoading = true;
      });
      try {
        _filePickerResult = await FilePicker.platform.pickFiles(
            type: FileType.any,
            allowedExtensions: (_extension?.isNotEmpty ?? false)
                ? _extension?.replaceAll(' ', '')?.split(',')
                : null);
      } on PlatformException catch (e) {
        print("Unsupported operation" + e.toString());
      }
      if (_filePickerResult != null) {
        setState(() {
          _pickedFile = File(_filePickerResult.files.single.path);
        });
      }
      if (!mounted) return;
      {
        Flushbar(
          showProgressIndicator: true,
          progressIndicatorBackgroundColor: Colors.blueGrey,
          title: 'Status:',
          message: 'File loaded: $_pickedFile',
          duration: Duration(seconds: 3),
          backgroundColor: Colors.green,
        )
          ..show(context);
      }
      setState(() {
        _isLoading = false;
      });
    }