Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[image_picker] Select any file with image_picker. #2856

Closed
wants to merge 3 commits into from

Conversation

ditman
Copy link
Member

@ditman ditman commented Jul 1, 2020

Description

This PR adds a Future<PickedFile> getFile({List<String> allowedExtensions}) method to the image_picker plugin, so users can select any arbitrary file from their device (not just images or videos).

This is the full PoC PR. In order for this to be merged, it needs to be split in 3 PRs: platform_interface, web version and finally, core plugin.

You can see a deployed version of this PR here:

This also adds a few extra fields to the PickedFile object: name and length(), to retrieve the file name and size (in bytes) of the picked file.

Related Issues

Other platforms

This seems doable in other platforms (but this PR only covers the web version).

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • No, this is not a breaking change.

Copy link
Member

@kenzieschmoll kenzieschmoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally seems like this plugin should now be named picker, but that change probably isn't feasible at the moment

@ditman
Copy link
Member Author

ditman commented Jul 1, 2020

Generally seems like this plugin should now be named picker, but that change probably isn't feasible at the moment

@kenzieschmoll indeed, however all the good names seem to be taken already (x_x)

@stuartmorgan-g
Copy link
Contributor

I just saw this PR (after commenting in the DevTools bug; this partially addresses some of my confusion there). Was there a discussion about this somewhere that led to a decision to add this to image_picker? If so, could you point me to it?

Desktop will need full open and save panel functionality; shoehorning all of it into image_picker seems like a very confusing way to solve that problem. It's not clear to me what the advantages of this approach are.

@ditman
Copy link
Member Author

ditman commented Jul 1, 2020

I just saw this PR (after commenting in the DevTools bug; this partially addresses some of my confusion there). Was there a discussion about this somewhere that led to a decision to add this to image_picker? If so, could you point me to it?

@stuartmorgan No, I did this as a PoC because the DevTools team needs picking files for their intern project, on Web and Desktop.

Desktop will need full open and save panel functionality; shoehorning all of it into image_picker seems like a very confusing way to solve that problem. It's not clear to me what the advantages of this approach are.

The advantage of this approach is just being able to reuse all the work made to image_picker to make it cross platform, basically PickedFile (that hides dart:io vs dart:html File differences). I'm not opposed to spinning this off to a separate plugin, if it exists.

@ditman
Copy link
Member Author

ditman commented Jul 6, 2020

Will turn this into a quick design doc to see where it can be landed.

@ditman ditman closed this Jul 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants