Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class GetDirectoryPage extends StatelessWidget {
Future<void> _getDirectoryPath(BuildContext context) async {
const confirmButtonText = 'Choose';
final String? directoryPath = await FileSelectorPlatform.instance
.getDirectoryPath(confirmButtonText: confirmButtonText);
.getDirectoryPathWithOptions(
const FileDialogOptions(confirmButtonText: confirmButtonText),
);
Comment on lines 15 to +19

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.

if (directoryPath == null) {
// Operation was canceled by the user.
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class GetMultipleDirectoriesPage extends StatelessWidget {
Future<void> _getDirectoryPaths(BuildContext context) async {
const confirmButtonText = 'Choose';
final List<String> directoryPaths = await FileSelectorPlatform.instance
.getDirectoryPaths(confirmButtonText: confirmButtonText);
.getDirectoryPathsWithOptions(
const FileDialogOptions(confirmButtonText: confirmButtonText),
);
Comment on lines 15 to +19

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.

if (directoryPaths.isEmpty) {
// Operation was canceled by the user.
return;
Expand Down