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

[file_selector] Update file_selector_platform_interface by adding the new property 'uniformTypeIdentifiers' to the XTypeGroup. #6433

Merged
merged 4 commits into from
Oct 18, 2022

Conversation

juandausa
Copy link
Contributor

Update file_selector_platform_interface by adding the new property 'uniformTypeIdentifiers' to the XTypeGroup.

  • Update file_selector_platform_interface by adding the new property 'uniformTypeIdentifiers'.

List which issues are fixed by this PR. You must list at least one issue.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@juandausa juandausa force-pushed the 103743-rename-property-macUTIs branch 2 times, most recently from 2a73760 to 6777bfb Compare September 16, 2022 11:38
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

Thanks for the submission!

@@ -26,7 +26,7 @@ class XTypeGroup {
final List<String>? mimeTypes;

/// The UTIs for this group
final List<String>? macUTIs;
List<String>? macUTIs;
Copy link
Contributor

Choose a reason for hiding this comment

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

This should stay final; there shouldn't be a setter for it. I forgot this was a conceptually immutable class when I wrote that example of forwarding constructs in the issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

(Filed flutter/flutter#111906 since this change shouldn't have been possible in the first place.)

@@ -50,6 +50,14 @@ class XTypeGroup {
(webWildCards?.isEmpty ?? true);
}

/// Returns the list of Uniform Type Identifiers for this group.
List<String>? get uniformTypeIdentifiers => macUTIs;
Copy link
Contributor

Choose a reason for hiding this comment

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

The field should be renamed, and the aliasing be done in the other direction, because the alias will be deprecated later, not the field.

Copy link
Contributor

Choose a reason for hiding this comment

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

Relatedly, the constructor needs to be updated to allow passing uniformTypeIdentifiers.

The behavior needs to be that we assert that they aren't both non-null, and then the field is set to uniformTypeIdentifiers ?? macUTIs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Stuart, currently the constructor allows null values for the macUTIs field. Do you mean that if both macUTIs and uniformTypeIdentifiers are null, we should just throw an exception? Wouldn't it be a breaking change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've been thinking about this, and now I understand that you meant if both are not null we should throw an exception, shouldn't we?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that's correct.

final List<String> extensions = <String>['txt', 'jpg'];
final List<String> mimeTypes = <String>['text/plain'];
final List<String> macUTIs = <String>['public.plain-text'];
final List<String> webWildCards = <String>['image/*'];
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert this change, and just inline whatever values you need in the new tests. Tests should generally be as localized as possible, to make them easy to understand and change in isolation.

@@ -1,5 +1,6 @@
## NEXT
## 2.1.1
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, and this should actually be 2.2.0 since it's new API.

@juandausa juandausa force-pushed the 103743-rename-property-macUTIs branch 2 times, most recently from 9f3c42b to ea39f35 Compare September 26, 2022 20:18
@baezfacundo baezfacundo force-pushed the 103743-rename-property-macUTIs branch from ea39f35 to f71fad5 Compare September 29, 2022 15:56
@eugerossetto eugerossetto force-pushed the 103743-rename-property-macUTIs branch from f71fad5 to 99441f6 Compare October 11, 2022 13:29
@adpinola
Copy link
Contributor

Hi @stuartmorgan we introduced the changes you requested, can you take a look again? Thanks.

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

Minor wording nits, and the test needs to be auto-formatted, but otherwise looks good!

@@ -1,3 +1,7 @@
## 2.3.0

* Adds the `uniformTypeIdentifiers` property to the `XTypeGroup` that relies on `macUTIs`. The last will be deprecated for future releases.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would be clearer as "Replaces macUTIs with uniformTypeIdentifiers. macUTIs is available as an alias, but will be deprecated in a future release."

This makes it clear that this is conceptually a replacement rather than a new property.

}) : _extensions = extensions;
}) : _extensions = extensions,
assert(uniformTypeIdentifiers == null || macUTIs == null,
'It is only allowed to specify either macUTIs or uniformTypeIdentifiers'),
Copy link
Contributor

Choose a reason for hiding this comment

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

"Only one of uniformTypeIdentifiers or macUTIs can be non-null"

@adpinola adpinola force-pushed the 103743-rename-property-macUTIs branch from 41e4a5c to 9c12e31 Compare October 11, 2022 17:54
@adpinola
Copy link
Contributor

Feedback applied.
Moving forward to replacing the old macUTIs, we will @Deprecate it, and then we should replace it with the new uniformTypeIdentifiers.
Can this be done in a single PR for all platforms, or we should create one to mark the property as deprecated and then replace it in one PR for each platform?

Thanks.

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

LGTM, @ditman for second review.

@stuartmorgan-g stuartmorgan-g requested a review from ditman October 11, 2022 18:57
@stuartmorgan-g
Copy link
Contributor

Moving forward to replacing the old macUTIs, we will @Deprecate it, and then we should replace it with the new uniformTypeIdentifiers. Can this be done in a single PR for all platforms, or we should create one to mark the property as deprecated and then replace it in one PR for each platform?

The order is:

  • publish the new API
  • update all of the code in flutter/plugins to use the new API instead of the old one
  • deprecate the old API

The last step can't be done before the previous one because it will break our CI analysis.

@adpinola adpinola force-pushed the 103743-rename-property-macUTIs branch 2 times, most recently from abfd0e3 to 0ec98e7 Compare October 14, 2022 13:20
@adpinola adpinola force-pushed the 103743-rename-property-macUTIs branch from 0ec98e7 to 875851c Compare October 14, 2022 20:38
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.

Thanks for the change, let's land this! My comment is totally optional, I normally don't asssert error messages; admittedly this implementation is more strict :)

Comment on lines +122 to +125
throwsA(predicate((Object? e) =>
e is AssertionError &&
e.message ==
'Only one of uniformTypeIdentifiers or macUTIs can be non-null')));
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a fan of asserting the text of the assertion error, I'd just do a expect(closure, throwsAssertionError) (or throwsA(isA<AssertionError>()))

@ditman ditman added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 18, 2022
@auto-submit auto-submit bot merged commit fd3ee38 into flutter:main Oct 18, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 18, 2022
…adding the new property 'uniformTypeIdentifiers' to the XTypeGroup. (flutter/plugins#6433)
adam-harwood pushed a commit to adam-harwood/flutter_plugins that referenced this pull request Nov 3, 2022
… new property 'uniformTypeIdentifiers' to the XTypeGroup. (flutter#6433)
mauricioluz pushed a commit to mauricioluz/plugins that referenced this pull request Jan 26, 2023
… new property 'uniformTypeIdentifiers' to the XTypeGroup. (flutter#6433)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: file_selector
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants