Skip to content

Conversation

stuartmorgan-g
Copy link
Collaborator

This deprecates getSavePath, which returned a target path string, in favor of a new getSaveLocation, 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

  • 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/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package 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.

confirmButtonText: confirmButtonText,
),
))
?.path;
Copy link
Member

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)?

Copy link
Collaborator Author

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.
Copy link
Member

Choose a reason for hiding this comment

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

pedantic nit: indent

Copy link
Collaborator Author

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}';
Copy link
Member

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)

Copy link
Collaborator Author

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) {
Copy link
Member

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);
Copy link
Member

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed everywhere.

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

LGTM stamp from a Japanese personal seal

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.

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!

@stuartmorgan-g
Copy link
Collaborator Author

I'll split out the first sub-PR shortly.

auto-submit bot pushed a commit that referenced this pull request Jun 21, 2023
auto-submit bot pushed a commit that referenced this pull request Jun 23, 2023
@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 23, 2023
@auto-submit auto-submit bot merged commit 25e1d87 into flutter:main Jun 23, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 26, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jun 26, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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.

3 participants