@@ -11,6 +11,7 @@ A Flutter plugin that manages files and interactions with file dialogs.
11
11
| ** Support** | iOS 9+ | Any | 10.11+ | Any | Windows 10+ |
12
12
13
13
## Usage
14
+
14
15
To use this plugin, add ` file_selector ` as a [ dependency in your pubspec.yaml file] ( https://flutter.dev/platform-plugins/ ) .
15
16
16
17
### macOS
@@ -28,10 +29,12 @@ or read/write access:
28
29
depending on your use case.
29
30
30
31
### Examples
32
+
31
33
Here are small examples that show you how to use the API.
32
34
Please also take a look at our [ example] [ example ] app.
33
35
34
36
#### Open a single file
37
+
35
38
<? code-excerpt "open_image_page.dart (SingleOpen)"?>
36
39
``` dart
37
40
const XTypeGroup typeGroup = XTypeGroup(
@@ -43,6 +46,7 @@ final XFile? file =
43
46
```
44
47
45
48
#### Open multiple files at once
49
+
46
50
<? code-excerpt "open_multiple_images_page.dart (MultiOpen)"?>
47
51
``` dart
48
52
const XTypeGroup jpgsTypeGroup = XTypeGroup(
@@ -59,7 +63,8 @@ final List<XFile> files = await openFiles(acceptedTypeGroups: <XTypeGroup>[
59
63
]);
60
64
```
61
65
62
- #### Saving a file
66
+ #### Save a file
67
+
63
68
<? code-excerpt "readme_standalone_excerpts.dart (Save)"?>
64
69
``` dart
65
70
const String fileName = 'suggested_name.txt';
@@ -76,6 +81,17 @@ final XFile textFile =
76
81
await textFile.saveTo(path);
77
82
```
78
83
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
+
79
95
### Filtering by file types
80
96
81
97
Different platforms support different type group filter options. To avoid
@@ -92,5 +108,14 @@ pass different `XTypeGroup`s based on `Platform`.
92
108
93
109
† ` mimeTypes ` are not supported on version of macOS earlier than 11 (Big Sur).
94
110
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
+
95
120
[ 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
0 commit comments