Skip to content

Conversation

@stuartmorgan-g
Copy link
Collaborator

The file_selector_linux example was using some methods that have been deprecated in favor of param-object versions. This updates to use those new versions.

The `file_selector_linux` example was using some methods that have been
deprecated in favor of param-object versions. This updates to use those
new versions.
@stuartmorgan-g stuartmorgan-g added the override: no changelog needed Override the check requiring CHANGELOG updates for most changes label Dec 1, 2025
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@stuartmorgan-g
Copy link
Collaborator Author

test-exempt: code refactor with no semantic change

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates two example files in file_selector_linux to replace deprecated method calls (getDirectoryPath and getDirectoryPaths) with their ...WithOptions counterparts (getDirectoryPathWithOptions and getDirectoryPathsWithOptions). My review includes suggestions to improve code conciseness by inlining a constant in both modified files, in line with Dart's style guide.

Comment on lines 15 to +19
const confirmButtonText = 'Choose';
final String? directoryPath = await FileSelectorPlatform.instance
.getDirectoryPath(confirmButtonText: confirmButtonText);
.getDirectoryPathWithOptions(
const FileDialogOptions(confirmButtonText: confirmButtonText),
);

Choose a reason for hiding this comment

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

medium

For conciseness, you can inline the confirmButtonText constant directly into the FileDialogOptions constructor. This avoids creating a local variable that is only used once, which is a general recommendation in the Dart style guide.1

Suggested change
const confirmButtonText = 'Choose';
final String? directoryPath = await FileSelectorPlatform.instance
.getDirectoryPath(confirmButtonText: confirmButtonText);
.getDirectoryPathWithOptions(
const FileDialogOptions(confirmButtonText: confirmButtonText),
);
final String? directoryPath = await FileSelectorPlatform.instance
.getDirectoryPathWithOptions(
const FileDialogOptions(confirmButtonText: 'Choose'),
);

Style Guide References

Footnotes

  1. The repository style guide states that code should follow the relevant style guides for each language. For Dart, this includes following 'Effective Dart' guidelines, which recommend avoiding local variables that are used only once.

Comment on lines 15 to +19
const confirmButtonText = 'Choose';
final List<String> directoryPaths = await FileSelectorPlatform.instance
.getDirectoryPaths(confirmButtonText: confirmButtonText);
.getDirectoryPathsWithOptions(
const FileDialogOptions(confirmButtonText: confirmButtonText),
);

Choose a reason for hiding this comment

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

medium

For conciseness, you can inline the confirmButtonText constant directly into the FileDialogOptions constructor. This avoids creating a local variable that is only used once, which is a general recommendation in the Dart style guide.1

Suggested change
const confirmButtonText = 'Choose';
final List<String> directoryPaths = await FileSelectorPlatform.instance
.getDirectoryPaths(confirmButtonText: confirmButtonText);
.getDirectoryPathsWithOptions(
const FileDialogOptions(confirmButtonText: confirmButtonText),
);
final List<String> directoryPaths = await FileSelectorPlatform.instance
.getDirectoryPathsWithOptions(
const FileDialogOptions(confirmButtonText: 'Choose'),
);

Style Guide References

Footnotes

  1. The repository style guide states that code should follow the relevant style guides for each language. For Dart, this includes following 'Effective Dart' guidelines, which recommend avoiding local variables that are used only once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

override: no changelog needed Override the check requiring CHANGELOG updates for most changes p: file_selector platform-linux

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant