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

Commit e92ede2

Browse files
[file_selector] Enable ArgumentErrors for type groups (#6126)
1 parent 9beb9a6 commit e92ede2

File tree

4 files changed

+40
-6
lines changed

4 files changed

+40
-6
lines changed

packages/file_selector/file_selector/CHANGELOG.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
## NEXT
1+
## 0.9.0
22

3-
* Ignores deprecation warnings for upcoming styleFrom button API changes.
3+
* **BREAKING CHANGE**: The following methods:
4+
* `openFile`
5+
* `openFiles`
6+
* `getSavePath`
7+
8+
can throw `ArgumentError`s if called with any `XTypeGroup`s that
9+
do not contain appropriate filters for the current platform. For
10+
example, an `XTypeGroup` that only specifies `webWildCards` will
11+
throw on non-web platforms.
12+
13+
To avoid runtime errors, ensure that all `XTypeGroup`s (other than
14+
wildcards) set filters that cover every platform your application
15+
targets. See the README for details.
416

517
## 0.8.4+3
618

packages/file_selector/file_selector/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,21 @@ final XFile textFile =
7676
await textFile.saveTo(path);
7777
```
7878

79+
### Filtering by file types
80+
81+
Different platforms support different type group filter options. To avoid
82+
`ArgumentError`s on some platforms, ensure that any `XTypeGroup`s you pass set
83+
filters that cover all platforms you are targeting, or that you conditionally
84+
pass different `XTypeGroup`s based on `Platform`.
85+
86+
| | macOS | Web | Windows |
87+
|----------------|--------|-----|-------------|
88+
| `extensions` | ✔️ | ✔️ | ✔️ |
89+
| `mimeTypes` | ✔️† | ✔️ | |
90+
| `macUTIs` | ✔️ | | |
91+
| `webWildCards` | | ✔️ | |
92+
93+
`mimeTypes` are not supported on version of macOS earlier than 11 (Big Sur).
94+
7995
[example]:./example
8096
[entitlement]: https://docs.flutter.dev/desktop#entitlements-and-the-app-sandbox

packages/file_selector/file_selector/lib/file_selector.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export 'package:file_selector_platform_interface/file_selector_platform_interfac
1717
/// options.
1818
/// - On macOS, the union of all types allowed by all of the groups will be
1919
/// allowed.
20+
/// Throws an [ArgumentError] if any type groups do not include filters
21+
/// supported by the current platform.
2022
///
2123
/// [initialDirectory] is the full path to the directory that will be displayed
2224
/// when the dialog is opened. When not provided, the platform will pick an
@@ -47,6 +49,8 @@ Future<XFile?> openFile({
4749
/// options.
4850
/// - On macOS, the union of all types allowed by all of the groups will be
4951
/// allowed.
52+
/// Throws an [ArgumentError] if any type groups do not include filters
53+
/// supported by the current platform.
5054
///
5155
/// [initialDirectory] is the full path to the directory that will be displayed
5256
/// when the dialog is opened. When not provided, the platform will pick an
@@ -75,6 +79,8 @@ Future<List<XFile>> openFiles({
7579
/// options.
7680
/// - On macOS, the union of all types allowed by all of the groups will be
7781
/// allowed.
82+
/// Throws an [ArgumentError] if any type groups do not include filters
83+
/// supported by the current platform.
7884
///
7985
/// [initialDirectory] is the full path to the directory that will be displayed
8086
/// when the dialog is opened. When not provided, the platform will pick an

packages/file_selector/file_selector/pubspec.yaml

Lines changed: 4 additions & 4 deletions
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.8.4+3
6+
version: 0.9.0
77

88
environment:
99
sdk: ">=2.12.0 <3.0.0"
@@ -20,10 +20,10 @@ flutter:
2020
default_package: file_selector_windows
2121

2222
dependencies:
23-
file_selector_macos: ^0.8.2
23+
file_selector_macos: ^0.9.0
2424
file_selector_platform_interface: ^2.0.0
25-
file_selector_web: ^0.8.1
26-
file_selector_windows: ^0.8.2
25+
file_selector_web: ^0.9.0
26+
file_selector_windows: ^0.9.0
2727
flutter:
2828
sdk: flutter
2929

0 commit comments

Comments
 (0)