.png 文件在 Flutter 中使用 Image Picker 是错误的吗?

Is it wrong to use Image Picker in Flutter for .png file?

使用 image_picker 到 select png 文件会记录错误,但应用程序运行正常(png 文件得到 selected)。我得到的错误

image_picker only supports compression for jpg files

我想将其用于 .png 文件。还能不能用?

使用 file_picker 包,https://pub.dev/packages/file_picker,(with 过滤器,类型:FileType.IMAGE) 而不是 image_picker 包使用 .png 而不会记录错误。

我认为使用 file_picker 插件是最好的选择。它是一个开发完善的插件,易于实施。

这是一个仅可用于 PNG 文件的示例实现。

  List<File> _paths;

  FileType _pickingType;

  bool _hasVailMime;

  Future<List<File>> _openImageFileExplorer() async {

    if(_pickingType != FileType.CUSTOM || _hasValidMime){
      try {
        _paths = await FilePicker.getMultiFile(   // Or getFile
            type: FileType.CUSTOM, fileExtension: 'png');
      }
      on PlatformException catch (e){
        print("Unsupported operation: " + e.toString());
      }
    }
    return _paths;
  }