-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[file_selector] Update Linux example for deprecations #10542
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
base: main
Are you sure you want to change the base?
[file_selector] Update Linux example for deprecations #10542
Conversation
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.
|
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. |
|
test-exempt: code refactor with no semantic 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.
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.
| const confirmButtonText = 'Choose'; | ||
| final String? directoryPath = await FileSelectorPlatform.instance | ||
| .getDirectoryPath(confirmButtonText: confirmButtonText); | ||
| .getDirectoryPathWithOptions( | ||
| const FileDialogOptions(confirmButtonText: confirmButtonText), | ||
| ); |
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.
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
| 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
-
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. ↩
| const confirmButtonText = 'Choose'; | ||
| final List<String> directoryPaths = await FileSelectorPlatform.instance | ||
| .getDirectoryPaths(confirmButtonText: confirmButtonText); | ||
| .getDirectoryPathsWithOptions( | ||
| const FileDialogOptions(confirmButtonText: confirmButtonText), | ||
| ); |
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.
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
| 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
-
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. ↩
The
file_selector_linuxexample was using some methods that have been deprecated in favor of param-object versions. This updates to use those new versions.