Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 655599b

Browse files
authored
[file_selector] Include the missing GetDirectoryPath method example and table of supported platforms (#6454)
1 parent 91122ec commit 655599b

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

packages/file_selector/file_selector/CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## 0.9.2+1
1+
## 0.9.2+2
22

3+
* Improves API docs and examples.
34
* Changes XTypeGroup initialization from final to const.
45
* Updates minimum Flutter version to 2.10.
56

packages/file_selector/file_selector/README.md

+27-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ A Flutter plugin that manages files and interactions with file dialogs.
1111
| **Support** | iOS 9+ | Any | 10.11+ | Any | Windows 10+ |
1212

1313
## Usage
14+
1415
To use this plugin, add `file_selector` as a [dependency in your pubspec.yaml file](https://flutter.dev/platform-plugins/).
1516

1617
### macOS
@@ -28,10 +29,12 @@ or read/write access:
2829
depending on your use case.
2930

3031
### Examples
32+
3133
Here are small examples that show you how to use the API.
3234
Please also take a look at our [example][example] app.
3335

3436
#### Open a single file
37+
3538
<?code-excerpt "open_image_page.dart (SingleOpen)"?>
3639
``` dart
3740
const XTypeGroup typeGroup = XTypeGroup(
@@ -43,6 +46,7 @@ final XFile? file =
4346
```
4447

4548
#### Open multiple files at once
49+
4650
<?code-excerpt "open_multiple_images_page.dart (MultiOpen)"?>
4751
``` dart
4852
const XTypeGroup jpgsTypeGroup = XTypeGroup(
@@ -59,7 +63,8 @@ final List<XFile> files = await openFiles(acceptedTypeGroups: <XTypeGroup>[
5963
]);
6064
```
6165

62-
#### Saving a file
66+
#### Save a file
67+
6368
<?code-excerpt "readme_standalone_excerpts.dart (Save)"?>
6469
```dart
6570
const String fileName = 'suggested_name.txt';
@@ -76,6 +81,17 @@ final XFile textFile =
7681
await textFile.saveTo(path);
7782
```
7883

84+
#### Get a directory path
85+
86+
<?code-excerpt "readme_standalone_excerpts.dart (GetDirectory)"?>
87+
```dart
88+
final String? directoryPath = await getDirectoryPath();
89+
if (directoryPath == null) {
90+
// Operation was canceled by the user.
91+
return;
92+
}
93+
```
94+
7995
### Filtering by file types
8096

8197
Different platforms support different type group filter options. To avoid
@@ -92,5 +108,14 @@ pass different `XTypeGroup`s based on `Platform`.
92108

93109
`mimeTypes` are not supported on version of macOS earlier than 11 (Big Sur).
94110

111+
### Features supported by platform
112+
113+
| Feature | Description | iOS | Linux | macOS | Windows | Web |
114+
| ---------------------- |----------------------------------- |--------- | ---------- | -------- | ------------ | ----------- |
115+
| Choose a single file | Pick a file/image | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
116+
| Choose multiple files | Pick multiple files/images | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
117+
| Choose a save location | Pick a directory to save a file in || ✔️ | ✔️ | ✔️ ||
118+
| Choose a directory | Pick a folder and get its path || ✔️ | ✔️ | ✔️ ||
119+
95120
[example]:./example
96-
[entitlement]: https://docs.flutter.dev/desktop#entitlements-and-the-app-sandbox
121+
[entitlement]: https://docs.flutter.dev/desktop#entitlements-and-the-app-sandbox

packages/file_selector/file_selector/example/lib/readme_standalone_excerpts.dart

+10
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,14 @@ class _MyAppState extends State<MyApp> {
5454
await textFile.saveTo(path);
5555
// #enddocregion Save
5656
}
57+
58+
Future<void> directoryPath() async {
59+
// #docregion GetDirectory
60+
final String? directoryPath = await getDirectoryPath();
61+
if (directoryPath == null) {
62+
// Operation was canceled by the user.
63+
return;
64+
}
65+
// #enddocregion GetDirectory
66+
}
5767
}

packages/file_selector/file_selector/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for opening and saving files, or selecting
33
directories, using native file selection UI.
44
repository: https://github.com/flutter/plugins/tree/main/packages/file_selector/file_selector
55
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
6-
version: 0.9.2+1
6+
version: 0.9.2+2
77

88
environment:
99
sdk: ">=2.12.0 <3.0.0"

0 commit comments

Comments
 (0)