-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[file_selector] Update file_selector_platform_interface by adding the new property 'uniformTypeIdentifiers' to the XTypeGroup. #6433
[file_selector] Update file_selector_platform_interface by adding the new property 'uniformTypeIdentifiers' to the XTypeGroup. #6433
Conversation
2a73760
to
6777bfb
Compare
There was a problem hiding this 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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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/*']; |
There was a problem hiding this comment.
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.
packages/file_selector/file_selector_platform_interface/test/x_type_group_test.dart
Show resolved
Hide resolved
@@ -1,5 +1,6 @@ | |||
## NEXT | |||
## 2.1.1 |
There was a problem hiding this comment.
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.
9f3c42b
to
ea39f35
Compare
ea39f35
to
f71fad5
Compare
f71fad5
to
99441f6
Compare
Hi @stuartmorgan we introduced the changes you requested, can you take a look again? Thanks. |
There was a problem hiding this 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. |
There was a problem hiding this comment.
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'), |
There was a problem hiding this comment.
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"
41e4a5c
to
9c12e31
Compare
Feedback applied. Thanks. |
There was a problem hiding this 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.
The order is:
The last step can't be done before the previous one because it will break our CI analysis. |
abfd0e3
to
0ec98e7
Compare
…niformTypeIdentifiers' to the XTypeGroup.
0ec98e7
to
875851c
Compare
There was a problem hiding this 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 :)
throwsA(predicate((Object? e) => | ||
e is AssertionError && | ||
e.message == | ||
'Only one of uniformTypeIdentifiers or macUTIs can be non-null'))); |
There was a problem hiding this comment.
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>())
)
…adding the new property 'uniformTypeIdentifiers' to the XTypeGroup. (flutter/plugins#6433)
… new property 'uniformTypeIdentifiers' to the XTypeGroup. (flutter#6433)
… new property 'uniformTypeIdentifiers' to the XTypeGroup. (flutter#6433)
Update file_selector_platform_interface by adding the new property 'uniformTypeIdentifiers' to the XTypeGroup.
List which issues are fixed by this PR. You must list at least one issue.
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.