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

[cross_file] An abstraction to allow working with files across multiple platforms. #3260

Merged
merged 13 commits into from
Nov 18, 2020

Conversation

mvanbeusekom
Copy link
Contributor

@mvanbeusekom mvanbeusekom commented Nov 10, 2020

Description

This PR copies the x_file type from the file_selector package into its own package. This will allow us to easily reuse this cross platform file abstraction in other plugins that are dealing with files, without having to duplicate the code.

At the moment there is a requirement to use this type in the camera plugin to be able to add the web implementation (suggestion to use x_file originated from @ditman, see here). Additional interest has been shown to use it in the image_picker plugin and cache_manager package.

Note: I took the liberty of renaming XFile to CrossFile since a package with the name "XFile" already exists on pub.dev but with a different purpose.

If this PR is accepted and the package is published, I will make sure to also migrate the file_selector plugin to use this new package and delete the internal implementation.

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?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

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

Is there a way that we can preserve @jasonpanelli's authorship on this package? Can we maybe add him as a co-author of one of your commits, and then ensure that when we merge he stays as a co-author?

Thanks!

@google-cla
Copy link

google-cla bot commented Nov 10, 2020

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Nov 10, 2020
@mvanbeusekom
Copy link
Contributor Author

@googlebot I consent.

@google-cla
Copy link

google-cla bot commented Nov 10, 2020

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@mvanbeusekom
Copy link
Contributor Author

@ditman thanks for the review. I have added the missing copyrights and immediately added @jasonpanelli as co-author. This however resulted in the CLA step failing since Jason now needs to also give his consent (which makes sense, but didn't think about it earlier).

Also I did a git mv when copying all files from the file_selector plugin, so if one would run for example git log --follow packages/cross-file/lib/src/types/base.dart you can still see the full history including all commits by @jasonpanelli.

@ditman
Copy link
Member

ditman commented Nov 10, 2020

Thanks for the extra effort @mvanbeusekom!

@jasonpanelli, when you have time, can you please tell googlebot you consent to this change? Thanks!

@ditman
Copy link
Member

ditman commented Nov 10, 2020

/cc @tugorez can you please also take a look at the new CrossFile, and see if it fits future usages or the ability to add extra metadata? Thanks!!

@ditman
Copy link
Member

ditman commented Nov 12, 2020

Quick note @mvanbeusekom: there's already some implementations coming for the file_selector plugin example.

I understand that the package name conflicts with something already in pub, and I think CrossFile is a good name for it; but could we maintain the name of the class that this package exports as XFile, so we can introduce the new package through the platform_interface in a backwards-compatible way?

(If we decide to go through with naming the class CrossFile, we'd need to bump the major version of the platform_interface package interface to introduce the new class name; this bump cascades to the implementations as well, because those would have an implementation that return an XFile, which then gets migrated to CrossFile)

@google-cla
Copy link

google-cla bot commented Nov 12, 2020

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@mvanbeusekom
Copy link
Contributor Author

Quick note @mvanbeusekom: there's already some implementations coming for the file_selector plugin example.

I understand that the package name conflicts with something already in pub, and I think CrossFile is a good name for it; but could we maintain the name of the class that this package exports as XFile, so we can introduce the new package through the platform_interface in a backwards-compatible way?

(If we decide to go through with naming the class CrossFile, we'd need to bump the major version of the platform_interface package interface to introduce the new class name; this bump cascades to the implementations as well, because those would have an implementation that return an XFile, which then gets migrated to CrossFile)

This is a good point. I have renamed the classes (and file names) back to XFile while keeping the package name CrossFile.

@ditman
Copy link
Member

ditman commented Nov 12, 2020

(I've pinged @jasonpanelli to get his approval!)

@google-cla
Copy link

google-cla bot commented Nov 12, 2020

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@jasonpanelli
Copy link
Contributor

@googlebot I consent.

@google-cla google-cla bot added cla: yes and removed cla: no labels Nov 12, 2020
@ditman
Copy link
Member

ditman commented Nov 12, 2020

Ah yes, I forgot to mention this check:

* The name of "lib/x_file.dart", "x_file", should match the name of the package, "cross_file".
  This helps users know what library to import.

@mvanbeusekom
Copy link
Contributor Author

Ah yes, I forgot to mention this check:

* The name of "lib/x_file.dart", "x_file", should match the name of the package, "cross_file".
  This helps users know what library to import.

Should be fixed now, CI is all green

Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

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

This is going to be great. If there's any issue with the merge, feel free to add me to the CODEOWNERS for this package!

@mvanbeusekom mvanbeusekom merged commit 0506742 into flutter:master Nov 18, 2020
@mvanbeusekom mvanbeusekom deleted the cross_file branch November 18, 2020 08:04
@ditman
Copy link
Member

ditman commented Nov 19, 2020

Note to all: package: cross_file is now a thing:

https://pub.dev/packages/cross_file

amantoux pushed a commit to amantoux/plugins that referenced this pull request Feb 8, 2021
…le platforms. (flutter#3260)

* Initial version of x_file package

* Renamed from x_file to cross_file

* Add back x_file type to file_selector

* Fix formatting issues

* Update homepage and version

* Added README.md

* Added missing copyright

* Revert "Added missing copyright"

This reverts commit cf7e8d5.

* Add missing copyright

Co-Authored-By: Jason Panelli <[email protected]>

* Renamed class implementation back to XFile

* Fix formatting issues

* Rename to cross_file

* Added code owners for cross_file package

Co-authored-by: Jason Panelli <[email protected]>
adsonpleal pushed a commit to nubank/plugins that referenced this pull request Feb 26, 2021
…le platforms. (flutter#3260)

* Initial version of x_file package

* Renamed from x_file to cross_file

* Add back x_file type to file_selector

* Fix formatting issues

* Update homepage and version

* Added README.md

* Added missing copyright

* Revert "Added missing copyright"

This reverts commit cf7e8d5.

* Add missing copyright

Co-Authored-By: Jason Panelli <[email protected]>

* Renamed class implementation back to XFile

* Fix formatting issues

* Rename to cross_file

* Added code owners for cross_file package

Co-authored-by: Jason Panelli <[email protected]>
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.

3 participants