-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[file_selector] Add file group to save return value #4222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[file_selector] Add file group to save return value #4222
Conversation
confirmButtonText: confirmButtonText, | ||
), | ||
)) | ||
?.path; |
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.
Was this intentional (or produced with dartfmt)?
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.
dartfmt
:( But @ditman's suggestion fixed it.
|
||
class OldFileSelectorPlatformImplementation extends FileSelectorPlatform { | ||
static const String savePath = '/a/path'; | ||
// Only implement the deprecated getSavePath. |
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.
pedantic nit: indent
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.
Fixed. I've never figured out when dart format
doesn't fix comment indentation.
if (!path.split(Platform.pathSeparator).last.contains('.')) { | ||
final XTypeGroup? activeGroup = result.activeFilter; | ||
if (activeGroup != null) { | ||
path = '$path.${activeGroup.extensions!.first}'; |
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.
Is the extensions list always guaranteed to contain at least one so long as there's an activeFilter? (That makes logical sense but it's a bummer we need to know it here)
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 is dependent on the code 15-20 lines up where we define the groups. I'll add a comment explaining that so it's clear to a reader why it's safe.
FileDialogResult result(files, nullptr); | ||
UINT file_type_index; | ||
if (SUCCEEDED(dialog_controller_->GetFileTypeIndex(&file_type_index)) && | ||
file_type_index > 0) { |
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.
😢 If this were pascal...
ASSERT_FALSE(result.has_error()); | ||
const EncodableList& paths = result.value(); | ||
const EncodableList& paths = result.value().paths(); | ||
EXPECT_EQ(paths.size(), 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.
Given the next line, arguably ASSERT_EQ
.
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.
Fixed everywhere.
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.
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.
Wow, what a big PR for a relatively small fix/feature!
The PR LGTM (I skipped .g.dart and .mock.dart files). Web bits look good (since they're pretty much a Noop). cpp stuff looks... almost intelligible :P
Thanks for fixing this!
packages/file_selector/file_selector/test/file_selector_test.dart
Outdated
Show resolved
Hide resolved
.../file_selector/file_selector_platform_interface/lib/src/types/file_save_location_result.dart
Outdated
Show resolved
Hide resolved
I'll split out the first sub-PR shortly. |
…ace (#4254) Platform interface portion of #4222 Part of flutter/flutter#107093
693c7b3
to
2ea2d71
Compare
…#4273) Implementation package portion of #4222 Part of flutter/flutter#107093
flutter/packages@d041934...6b70804 2023-06-23 [email protected] [go_router] Reduces excessive rebuilds due to inherited look up. (flutter/packages#4227) 2023-06-23 [email protected] [image_picker] Update to 1.0 (flutter/packages#4285) 2023-06-23 [email protected] [tool] Consider comment-only changes to be dev-only (flutter/packages#4279) 2023-06-23 [email protected] [ci] Switch to LUCI for Android build-all (flutter/packages#4274) 2023-06-23 [email protected] [file_selector] Add file group to save return value (flutter/packages#4222) 2023-06-23 [email protected] [go_router] Adds onException to GoRouter constructor. (flutter/packages#4216) 2023-06-23 [email protected] [file_selector] Add file group to save return value - implementations (flutter/packages#4273) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
This deprecates
getSavePath
, which returned a target path string, in favor of a newgetSaveLocation
, which returns an object containing both a path and, optionally, a selected file group. This allows clients to use the selected group when deciding what path to use when saving (see discussion in linked issue).This includes an implementation for Windows. It will also apply to Linux, and I've verified that the structure works, but it's not included here because it requires some non-trivial refactoring in the Linux implementation (we can't get the current index, only the current filter object pointer, which means we need to pass more data around between the various functions to map back to an index... and it's GObject so making internal data utility classes is fiddly.) For now Linux just always returns a null group, and we can add it later.
Most of flutter/flutter#107093
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.