-
Notifications
You must be signed in to change notification settings - Fork 665
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
Please add a "save as" / "new file" dialog #799
Comments
@philenius could it be done? |
@miguelpruivo yes, I already have a working implementation for a save-as dialog on Windows, Linux, and macOS. The current implementation (in my old Dart package) offers a separate method final String? selectedFileName = await saveFile(
defaultFileName: 'default-file.txt',
); . I could easily adapt it to return |
I believe that picking directories is enough and serves the same purpose on mobile. |
@miguelpruivo could you please resend the invitation for your repository so that I can contribute? Sorry to bother you again. The original invitation has expired because I was on vacation in the meantime. Thank you. Concerning this issue:
Unfortunately, we'll need one more additional parameter to set the default file name (the save-file-dialog includes a title, a file type filter, and a default file name). So, the final API could look like this: Future<FilePickerResult?> pickFiles({
String? dialogTitle,
FileType type = FileType.any,
List<String>? allowedExtensions,
Function(FilePickerStatus)? onFileLoading,
bool allowCompression = true,
bool allowMultiple = false,
bool withData = false,
bool withReadStream = false,
// NEW:
bool saveFileDialog = false,
// ALSO NEW:
String? defaultFileName,
}) async { ... } Knowing that we'll need two additional parameters, do you still want to integrate the save-file-dialog in the existing function |
@philenius I'm afraid this could confuse IO users with even more parameters, however, if it's handy for some, I don't see a reason why we shouldn't add it as well. I'm trying to understand what is this feature about — it's just to pick a location without picking the files? If so, the best approach would be adding a desktop implementation only for saving the files with a new method, something like |
@miguelpruivo, exactly, that was my thought, too. Too many parameters can become confusing. You go the idea right. A save-file dialog allows the user to select an output file. In the example of a tool for creating PDF files: the user can select the path and name of the output file (either an existing file or a new file) to which the program will write/export the PDF file. The return value of the save-file dialog is only the path to the file. I like your idea of providing FilePicker.instance.saveAs({
String? dialogTitle,
String? fileName,
FileType type = FileType.any,
List<String>? allowedExtensions
}) for desktop platforms and throwing an exception on mobile platforms. If you add me as a contributor, then I'd love to do the implementation. |
@philenius are the file type and extensions required for that as well? Sure I’ll add you right away. |
@miguelpruivo: the decision is up to you whether file type and extensions can be configured, too. At least it has an effect on Windows and Linux: 1.Allow any file types:
On macOS, I wasn't able to filter by file type. Although, the dialog in @jonmountjoy 's screenshot (first message in this issue) shows a dropdown for setting the allowed file types. |
I much prefer the proposed direction of creating a new API method as you're doing in #799 (comment) , than my original proposal. 👍 |
@philenius already invited you. Yes, looks like a good approach, you're good to go. |
Hello!
Would it be possible to extend the native dialogs to handle the "Save As" action. It's similar to the directory selection that's already there, but provides a text field for the file name, as shown below for MacOS:
This could be an entirely new API method I guess, or perhaps extend
FileType
with asave
option, and allow something like:Thanks!
The text was updated successfully, but these errors were encountered: