[file_selector] Enable ArgumentErrors for type groups (#6126)
diff --git a/packages/file_selector/file_selector/CHANGELOG.md b/packages/file_selector/file_selector/CHANGELOG.md
index db29f82..356e9ff 100644
--- a/packages/file_selector/file_selector/CHANGELOG.md
+++ b/packages/file_selector/file_selector/CHANGELOG.md
@@ -1,6 +1,18 @@
-## NEXT
+## 0.9.0
-* Ignores deprecation warnings for upcoming styleFrom button API changes.
+* **BREAKING CHANGE**: The following methods:
+ * `openFile`
+ * `openFiles`
+ * `getSavePath`
+
+ can throw `ArgumentError`s if called with any `XTypeGroup`s that
+ do not contain appropriate filters for the current platform. For
+ example, an `XTypeGroup` that only specifies `webWildCards` will
+ throw on non-web platforms.
+
+ To avoid runtime errors, ensure that all `XTypeGroup`s (other than
+ wildcards) set filters that cover every platform your application
+ targets. See the README for details.
## 0.8.4+3
diff --git a/packages/file_selector/file_selector/README.md b/packages/file_selector/file_selector/README.md
index f5c1de8..a451533 100644
--- a/packages/file_selector/file_selector/README.md
+++ b/packages/file_selector/file_selector/README.md
@@ -76,5 +76,21 @@
await textFile.saveTo(path);
```
+### Filtering by file types
+
+Different platforms support different type group filter options. To avoid
+`ArgumentError`s on some platforms, ensure that any `XTypeGroup`s you pass set
+filters that cover all platforms you are targeting, or that you conditionally
+pass different `XTypeGroup`s based on `Platform`.
+
+| | macOS | Web | Windows |
+|----------------|--------|-----|-------------|
+| `extensions` | ✔️ | ✔️ | ✔️ |
+| `mimeTypes` | ✔️† | ✔️ | |
+| `macUTIs` | ✔️ | | |
+| `webWildCards` | | ✔️ | |
+
+† `mimeTypes` are not supported on version of macOS earlier than 11 (Big Sur).
+
[example]:./example
[entitlement]: https://docs.flutter.dev/desktop#entitlements-and-the-app-sandbox
diff --git a/packages/file_selector/file_selector/lib/file_selector.dart b/packages/file_selector/file_selector/lib/file_selector.dart
index 322ae6c..f357af0 100644
--- a/packages/file_selector/file_selector/lib/file_selector.dart
+++ b/packages/file_selector/file_selector/lib/file_selector.dart
@@ -17,6 +17,8 @@
/// options.
/// - On macOS, the union of all types allowed by all of the groups will be
/// allowed.
+/// Throws an [ArgumentError] if any type groups do not include filters
+/// supported by the current platform.
///
/// [initialDirectory] is the full path to the directory that will be displayed
/// when the dialog is opened. When not provided, the platform will pick an
@@ -47,6 +49,8 @@
/// options.
/// - On macOS, the union of all types allowed by all of the groups will be
/// allowed.
+/// Throws an [ArgumentError] if any type groups do not include filters
+/// supported by the current platform.
///
/// [initialDirectory] is the full path to the directory that will be displayed
/// when the dialog is opened. When not provided, the platform will pick an
@@ -75,6 +79,8 @@
/// options.
/// - On macOS, the union of all types allowed by all of the groups will be
/// allowed.
+/// Throws an [ArgumentError] if any type groups do not include filters
+/// supported by the current platform.
///
/// [initialDirectory] is the full path to the directory that will be displayed
/// when the dialog is opened. When not provided, the platform will pick an
diff --git a/packages/file_selector/file_selector/pubspec.yaml b/packages/file_selector/file_selector/pubspec.yaml
index 12a1fbc..51eb0a4 100644
--- a/packages/file_selector/file_selector/pubspec.yaml
+++ b/packages/file_selector/file_selector/pubspec.yaml
@@ -3,7 +3,7 @@
directories, using native file selection UI.
repository: https://github.com/flutter/plugins/tree/main/packages/file_selector/file_selector
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
-version: 0.8.4+3
+version: 0.9.0
environment:
sdk: ">=2.12.0 <3.0.0"
@@ -20,10 +20,10 @@
default_package: file_selector_windows
dependencies:
- file_selector_macos: ^0.8.2
+ file_selector_macos: ^0.9.0
file_selector_platform_interface: ^2.0.0
- file_selector_web: ^0.8.1
- file_selector_windows: ^0.8.2
+ file_selector_web: ^0.9.0
+ file_selector_windows: ^0.9.0
flutter:
sdk: flutter