Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1254 so that the current directory is not changed after the used picked files #1256

Merged

Conversation

philenius
Copy link
Collaborator

@philenius philenius commented Apr 6, 2023

Important changes:

  • Fixes the bug that the current directory sometimes changed after the user picked a file. Now, after the dialog is closed, the current directory is automatically restored to its original value even if the user changed the directory while searching for files (#1254).
  • In my previous pull request for v5.2.7, I forgot to commit my Linux implementation 馃槥 This pull request fixes the behavior of the saveFile() dialog on Ubuntu/Kubuntu. This fix should have been committed in the previous version 5.2.7 but was forgotten. Now, when the user selects an already existing file, then Ubuntu prompts the user to confirm overwriting this file. This change finally makes the dialog behave the same on all desktop platforms (macOS, Linux, and Windows) (#989).

Less important changes:

  • I refactored the Windows implementation by replacing parameters by an instance of the class _OpenSaveFileArgs.
    The class _OpenSaveFileArgs has been introduced in f56fac2. However, it wasn't used consistently throughout the whole Windows implementation as each field of _OpenSaveFileArgs was passed individually between functions. Consistenly using an instance of _OpenSaveFileArgs minifies function signatures and reduces the total lines of code by 50 lines.
  • Chore: fixed the linter error "unnecessay_import"

    The import of 'dart:typed_data' is unnecessary because all the used elements are also provided by the import of
    package:flutter/foundation.dart'.

  • Example app: I re-created our example app and gave it a new Material 3 design. I also added additional input elements to demonstrate the effects of the parameters dialogTitle, initialDirectory, fileName, and lockParentWindow. Sorry for the many new files but they are part of Flutter apps for Windows / Linux and they are not part of the official Flutter .gitignore.

鈩癸笍 @miguelpruivo, if you you want me to put screenshots/videos from the updated example app into the README, then please let me know. Also, please note that I have not tested the updated example app on iOS because I don't have access to an iPhone.

Windows:

windows

Linux:

linux.mp4

Android:

android.mp4

Previously, on Windows, the current directory changed after picking
a file. Turns out, there's an extra option to restore the current
directory after picking a file or directory.
The class `_OpenSaveFileArgs` has been introduced in
f56fac2. However, it wasn't used
consistently throughout the whole Windows implementation as each field
of `_OpenSaveFileArgs` was passed individually between functions.
Consistenly using an instance of `_OpenSaveFileArgs` minifies function
signatures and reduces the total lines of code by 50 lines.
Linter error: the import of 'dart:typed_data' is unnecessary because all
of the used elements are also provided by the import of
package:flutter/foundation.dart'.
Prompts the user for confirmation when selecting an already existing
file on Ubuntu.
This should have been committed in the previous file_picker
version 5.2.7, but I totally forgot :/
@philenius philenius linked an issue Apr 6, 2023 that may be closed by this pull request
@philenius philenius added the desktop The issue applies to Windows, Linux or MacOS implementations. label Apr 6, 2023
@philenius philenius force-pushed the bugfix/#1254-current-directory-changes-after-picking-files branch from c1b347f to 178edb9 Compare April 6, 2023 22:44
@philenius philenius marked this pull request as ready for review April 7, 2023 11:32
@miguelpruivo
Copy link
Owner

@philenius thank you for your effort. If you think it could add some value having the screenshots there, feel free to add so (in reasonable sizes).

@philenius philenius force-pushed the bugfix/#1254-current-directory-changes-after-picking-files branch 3 times, most recently from d94d2f3 to 41cc575 Compare April 11, 2023 22:56
@philenius philenius force-pushed the bugfix/#1254-current-directory-changes-after-picking-files branch from 41cc575 to 3e6817f Compare April 11, 2023 23:21
@miguelpruivo miguelpruivo merged commit 7f00932 into master Apr 12, 2023
@miguelpruivo miguelpruivo deleted the bugfix/#1254-current-directory-changes-after-picking-files branch April 12, 2023 01:14
@miguelpruivo
Copy link
Owner

@philenius I have merged to find that some of the readme images are broken now. I鈥檓 not sure if you were done with this PR but if not, feel free to add the missing changes and/or I鈥檒l revert it back to the previous version ASAP.

Sorry for any inconvenience.

@miguelslemos
Copy link

#1260

@philenius
Copy link
Collaborator Author

@philenius I have merged to find that some of the readme images are broken now. I鈥檓 not sure if you were done with this PR but if not, feel free to add the missing changes and/or I鈥檒l revert it back to the previous version ASAP.

Sorry for any inconvenience.

Sorry, my bad, I wasn't done with my PR. I should have marked the PR as a draft.
I created a new PR to fix the broken GIFs and another big. See #1261

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop The issue applies to Windows, Linux or MacOS implementations.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The current directory was changed after pick a file
3 participants