Skip to content

Conversation

@danferreira
Copy link

@danferreira danferreira commented Sep 6, 2025

Adds a new parameter canCreateDirectories to FileDialogOptions to control the visibility of the New Folder button in file dialogs on supported platforms.

Currently only configurable on Linux and macOS

This is the "Combined PR"
Let me know if we are okay with this approach so I can open a new PR covering the interface changes

Fixes: flutter/flutter#141339

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

Copy link
Collaborator

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

///
/// [canCreateDirectories] controls whether the user is allowed to create new
/// directories in the dialog (if supported on the platform).
/// Currently only supported on Linux and macOS.
Copy link
Collaborator

Choose a reason for hiding this comment

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

The app-facing package has no control over this, so it's subject to becoming stale (and misleading about unendorsed implementations). It should just say that it may not be supported on all platforms.

Copy link
Author

Choose a reason for hiding this comment

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

Agree. I changed the doc so that it infers less about the implementations
Let me know what you think

## NEXT
## 1.1.0

* Adds `canCreateDirectories` parameter to `FileDialogOptions` to control the visibility of the New Folder button in file dialogs on supported platforms.
Copy link
Collaborator

Choose a reason for hiding this comment

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

FileDialogOptions shouldn't be mentioned at this level, since it's not the public API here.

Copy link
Author

@danferreira danferreira Sep 11, 2025

Choose a reason for hiding this comment

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

Makes total sense.

Fixed manually all changelogs

const String initialDirectory = '/home/flutteruser';
const String confirmButtonText = 'Use this profile picture';
const String suggestedName = 'suggested_name';
const bool canCreateDirectories = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's no need for this to be stateful in the tests; values should be local.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This file shouldn't be changed; it's for legacy compat, and legacy implementations won't support new features.

@stuartmorgan-g stuartmorgan-g removed the request for review from ditman October 10, 2025 15:35
Copy link
Collaborator

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

Sorry for the delay in getting back to this. A few more comments on the cross-platform parts.

expect(location?.path, expectedSavePath);
});

test('sets to disable the creation of new directories', () async {
Copy link
Collaborator

Choose a reason for hiding this comment

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

'sets the directory creation control flag'

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

expect(directoryPath, expectedDirectoryPath);
});

test('sets to enable de creation of new directories', () async {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

);
expect(directoryPaths, expectedDirectoryPaths);
});
test('sets to enable de creation of new directories', () async {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

## NEXT
## 1.1.0

* Adds `canCreateDirectories` param to `getDirectoryPath` and `getDirectoryPaths` to control the visibility of the New Folder button in file dialogs on supported platforms.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should not be describing an exact UI element, because this layer has no control over what the specific UI is.

Copy link
Author

Choose a reason for hiding this comment

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

Ah, I get it now. It makes sense.
I will describe the behavior instead.

});

group('getDirectoryPathWithOptions', () {
test('Should throw unimplemented exception', () async {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here and below: that's not what we want to test for the new methods. The implementations of the new methods should not throw UnimplementedError, because that would break backward compatibility when the app-facing package change lands. They must call the deprecated methods, and that's what the test should be testing.

Copy link
Author

Choose a reason for hiding this comment

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

I see.
I didn't even realize the getSaveLocation test was doing exactly what you described.
I'll update the mentioned tests to check if the deprecated methods were called.

@stuartmorgan-g stuartmorgan-g added triage-ios Should be looked at in iOS triage triage-android Should be looked at in Android triage labels Oct 10, 2025
@danferreira danferreira force-pushed the file_selector-can-create-directories-param branch from cb4e65c to 0b3beb5 Compare October 22, 2025 00:08
@danferreira
Copy link
Author

Sorry for the delay in getting back to this. A few more comments on the cross-platform parts.

I appreciate your patience
I'd never worked with a Flutter codebase before, so I was a bit confused by the plugin package structure.
But thanks to your comments, things are starting to make sense now.
Im learning a lot.

Copy link
Contributor

@vashworth vashworth left a comment

Choose a reason for hiding this comment

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

iOS side LGTM

Copy link
Collaborator

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

Overall this looks good; please go ahead and split out the platform interface initial PR now and we can get that reviewed and landed. (Normally we'd wait for all the platform reviews for that, but I've looked over all of them, and they are straightforward enough that we don't need to block the interface PR on that.)

@camsim99 camsim99 removed their request for review October 27, 2025 16:48
Copy link
Member

@gmackall gmackall left a comment

Choose a reason for hiding this comment

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

android portion lgtm

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[file_selector] Do not have create directory button at bottom

4 participants