1

Using image_picker to select png files logs an error but the app works fine(the png file gets selected). The error i get

image_picker only supports compression for jpg files

I want to use it for .png files. Can I still use it or not?

2 Answers 2

1

Using file_picker package, https://pub.dev/packages/file_picker,(with filter, type: FileType.IMAGE) instead of image_picker package works with .png without logging an error.

Sign up to request clarification or add additional context in comments.

Comments

1

I think that using the file_picker plugin would be the best option for this. It is a well developed plugin and easily implemented.

Here is an example implementation that you could use for PNG files only.

  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;
  }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.