Skip to content

Conversation

@danferreira
Copy link
Contributor

@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
Contributor 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
Contributor 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
Contributor 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
Contributor 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
Contributor 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
Contributor 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
Contributor 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
@stuartmorgan-g
Copy link
Collaborator

@danferreira Please proceed with splitting out a PR with all the platform implementations now, and we can get that landed next (see the note in step 5 here).

@danferreira
Copy link
Contributor Author

danferreira commented Nov 16, 2025

@danferreira Please proceed with splitting out a PR with all the platform implementations now, and we can get that landed next (see the note in step 5 here).

Thanks for the direction @stuartmorgan-g
I ended up making changes on platforms that doesnt support this new parameter (web, windows and android) creating a lot of "noise"

Should I update all other platforms on the new PR or only the ones affected (macos, linux)?
PR with macos and linux platform integrations: #10443

I noticed platform interface for iOS is a bit outdated compared to the others so I assume we only update when needed/is used, right?

auto-submit bot pushed a commit that referenced this pull request Nov 21, 2025
…0443)

Updates macos and linux `file_selector` platforms to implement the new `canCreateDirectories` parameter from platform interface

Until now, only macos and linux are able to override this parameter

This is the "platform implementations" step for #9965

Part of: flutter/flutter#141339

## Pre-Review Checklist

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). 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.

[^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.
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.

LGTM, thanks for getting this updated so quickly!

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 21, 2025
@auto-submit auto-submit bot merged commit 6a84a54 into flutter:main Nov 21, 2025
80 checks passed
@danferreira danferreira deleted the file_selector-can-create-directories-param branch November 21, 2025 19:32
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 24, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 24, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 24, 2025
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Nov 24, 2025
flutter/packages@e67b6be...e019cf9

2025-11-24 [email protected] [Android 16] Bump Packages to
Robolectric 4.16 (flutter/packages#10492)
2025-11-24 [email protected] Roll Flutter from
c8cfb2b to 3f553f6 (11 revisions) (flutter/packages#10510)
2025-11-24 49699333+dependabot[bot]@users.noreply.github.com
[dependabot]: Bump the test-dependencies group across 6 directories with
2 updates (flutter/packages#10500)
2025-11-22 [email protected] Roll Flutter from
d438df3 to c8cfb2b (21 revisions) (flutter/packages#10494)
2025-11-21 [email protected] [webview_flutter] Update Pigeon for
Kotlin 1.8 compat (flutter/packages#10486)
2025-11-21 49699333+dependabot[bot]@users.noreply.github.com
[dependabot]: Bump the gradle-plugin group across 19 directories with 1
update (flutter/packages#10456)
2025-11-21 [email protected] [file_selector] Add parameter to
control whether the new folders button is visible in the file dialog
(flutter/packages#9965)
2025-11-21 [email protected] Roll Flutter from
9f383e0 to d438df3 (18 revisions) (flutter/packages#10491)
2025-11-21 [email protected] Roll Flutter (stable) from
f5a8537 to 19074d1 (2 revisions) (flutter/packages#10489)

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] 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://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
mboetger pushed a commit to mboetger/flutter that referenced this pull request Dec 2, 2025
flutter/packages@e67b6be...e019cf9

2025-11-24 [email protected] [Android 16] Bump Packages to
Robolectric 4.16 (flutter/packages#10492)
2025-11-24 [email protected] Roll Flutter from
c8cfb2b to 3f553f6 (11 revisions) (flutter/packages#10510)
2025-11-24 49699333+dependabot[bot]@users.noreply.github.com
[dependabot]: Bump the test-dependencies group across 6 directories with
2 updates (flutter/packages#10500)
2025-11-22 [email protected] Roll Flutter from
d438df3 to c8cfb2b (21 revisions) (flutter/packages#10494)
2025-11-21 [email protected] [webview_flutter] Update Pigeon for
Kotlin 1.8 compat (flutter/packages#10486)
2025-11-21 49699333+dependabot[bot]@users.noreply.github.com
[dependabot]: Bump the gradle-plugin group across 19 directories with 1
update (flutter/packages#10456)
2025-11-21 [email protected] [file_selector] Add parameter to
control whether the new folders button is visible in the file dialog
(flutter/packages#9965)
2025-11-21 [email protected] Roll Flutter from
9f383e0 to d438df3 (18 revisions) (flutter/packages#10491)
2025-11-21 [email protected] Roll Flutter (stable) from
f5a8537 to 19074d1 (2 revisions) (flutter/packages#10489)

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] 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://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
flutter/packages@e67b6be...e019cf9

2025-11-24 [email protected] [Android 16] Bump Packages to
Robolectric 4.16 (flutter/packages#10492)
2025-11-24 [email protected] Roll Flutter from
c8cfb2b to 3f553f6 (11 revisions) (flutter/packages#10510)
2025-11-24 49699333+dependabot[bot]@users.noreply.github.com
[dependabot]: Bump the test-dependencies group across 6 directories with
2 updates (flutter/packages#10500)
2025-11-22 [email protected] Roll Flutter from
d438df3 to c8cfb2b (21 revisions) (flutter/packages#10494)
2025-11-21 [email protected] [webview_flutter] Update Pigeon for
Kotlin 1.8 compat (flutter/packages#10486)
2025-11-21 49699333+dependabot[bot]@users.noreply.github.com
[dependabot]: Bump the gradle-plugin group across 19 directories with 1
update (flutter/packages#10456)
2025-11-21 [email protected] [file_selector] Add parameter to
control whether the new folders button is visible in the file dialog
(flutter/packages#9965)
2025-11-21 [email protected] Roll Flutter from
9f383e0 to d438df3 (18 revisions) (flutter/packages#10491)
2025-11-21 [email protected] Roll Flutter (stable) from
f5a8537 to 19074d1 (2 revisions) (flutter/packages#10489)

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] 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://issues.skia.org/issues/new?component=1389291&template=1850622

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 platform-macos triage-ios Should be looked at in iOS triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[file_selector] Do not have create directory button at bottom

6 participants