Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/file_selector/file_selector/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 0.9.2+5

* Updates references to the deprecated `macUTIs`.
* Aligns Dart and Flutter SDK constraints.

## 0.9.2+4
Expand Down
14 changes: 7 additions & 7 deletions packages/file_selector/file_selector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ Different platforms support different type group filter options. To avoid
filters that cover all platforms you are targeting, or that you conditionally
pass different `XTypeGroup`s based on `Platform`.

| | Linux | macOS | Web | Windows |
|----------------|-------|--------|-----|-------------|
| `extensions` | ✔️ | ✔️ | ✔️ | ✔️ |
| `mimeTypes` | ✔️ | ✔️† | ✔️ | |
| `macUTIs` | | ✔️ | | |
| `webWildCards` | | | ✔️ | |
| | iOS | Linux | macOS | Web | Windows |
|--------------------------|-----|-------|--------|-----|-------------|
| `extensions` | | ✔️ | ✔️ | ✔️ | ✔️ |
| `mimeTypes` | | ✔️ | ✔️† | ✔️ | |
| `uniformTypeIdentifiers` | ✔️ | | ✔️ | | |
| `webWildCards` | | | | ✔️ | |

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

Expand All @@ -118,4 +118,4 @@ pass different `XTypeGroup`s based on `Platform`.
| Choose a directory | Pick a folder and get its path | ❌ | ✔️ | ✔️ | ✔️ | ❌ |

[example]:./example
[entitlement]: https://docs.flutter.dev/desktop#entitlements-and-the-app-sandbox
[entitlement]: https://docs.flutter.dev/desktop#entitlements-and-the-app-sandbox
4 changes: 2 additions & 2 deletions packages/file_selector/file_selector/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for opening and saving files, or selecting
directories, using native file selection UI.
repository: https://github.com/flutter/packages/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.9.2+4
version: 0.9.2+5

environment:
sdk: ">=2.17.0 <4.0.0"
Expand All @@ -27,7 +27,7 @@ dependencies:
file_selector_ios: ^0.5.0
file_selector_linux: ^0.9.0
file_selector_macos: ^0.9.0
file_selector_platform_interface: ^2.2.0
file_selector_platform_interface: ^2.3.0
file_selector_web: ^0.9.0
file_selector_windows: ^0.9.0
flutter:
Expand Down
4 changes: 4 additions & 0 deletions packages/file_selector/file_selector_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.1+4

* Updates references to the deprecated `macUTIs`.

## 0.5.1+3

* Updates pigeon to fix warnings with clang 15.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class OpenImagePage extends StatelessWidget {
const XTypeGroup typeGroup = XTypeGroup(
label: 'images',
extensions: <String>['jpg', 'png'],
macUTIs: <String>['public.image'],
uniformTypeIdentifiers: <String>['public.image'],
);
final XFile? file = await FileSelectorPlatform.instance
.openFile(acceptedTypeGroups: <XTypeGroup>[typeGroup]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ class OpenMultipleImagesPage extends StatelessWidget {
const XTypeGroup jpgsTypeGroup = XTypeGroup(
label: 'JPEGs',
extensions: <String>['jpg', 'jpeg'],
macUTIs: <String>['public.jpeg'],
uniformTypeIdentifiers: <String>['public.jpeg'],
);
const XTypeGroup pngTypeGroup = XTypeGroup(
label: 'PNGs',
extensions: <String>['png'],
macUTIs: <String>['public.png'],
uniformTypeIdentifiers: <String>['public.png'],
);
final List<XFile> files = await FileSelectorPlatform.instance
.openFiles(acceptedTypeGroups: <XTypeGroup>[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class OpenTextPage extends StatelessWidget {
const XTypeGroup typeGroup = XTypeGroup(
label: 'text',
extensions: <String>['txt', 'json'],
macUTIs: <String>['public.text'],
uniformTypeIdentifiers: <String>['public.text'],
);
final XFile? file = await FileSelectorPlatform.instance
.openFile(acceptedTypeGroups: <XTypeGroup>[typeGroup]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ class FileSelectorIOS extends FileSelectorPlatform {
if (typeGroup.allowsAny) {
return <String>[];
}
if (typeGroup.macUTIs?.isEmpty ?? true) {
if (typeGroup.uniformTypeIdentifiers?.isEmpty ?? true) {
throw ArgumentError('The provided type group $typeGroup should either '
'allow all files, or have a non-empty "macUTIs"');
'allow all files, or have a non-empty "uniformTypeIdentifiers"');
}
allowedUTIs.addAll(typeGroup.macUTIs!);
allowedUTIs.addAll(typeGroup.uniformTypeIdentifiers!);
}
return allowedUTIs;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/file_selector/file_selector_ios/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: file_selector_ios
description: iOS implementation of the file_selector plugin.
repository: https://github.com/flutter/packages/tree/main/packages/file_selector/file_selector_ios
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
version: 0.5.1+3
version: 0.5.1+4

environment:
sdk: ">=2.18.0 <4.0.0"
Expand All @@ -17,7 +17,7 @@ flutter:
pluginClass: FFSFileSelectorPlugin

dependencies:
file_selector_platform_interface: ^2.2.0
file_selector_platform_interface: ^2.3.0
flutter:
sdk: flutter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ void main() {
label: 'text',
extensions: <String>['txt'],
mimeTypes: <String>['text/plain'],
macUTIs: <String>['public.text'],
uniformTypeIdentifiers: <String>['public.text'],
);

const XTypeGroup groupTwo = XTypeGroup(
label: 'image',
extensions: <String>['jpg'],
mimeTypes: <String>['image/jpg'],
macUTIs: <String>['public.image'],
uniformTypeIdentifiers: <String>['public.image'],
webWildCards: <String>['image/*']);

await plugin.openFile(acceptedTypeGroups: <XTypeGroup>[group, groupTwo]);
Expand All @@ -56,7 +56,7 @@ void main() {
final FileSelectorConfig config =
result.captured[0] as FileSelectorConfig;

// iOS only accepts macUTIs.
// iOS only accepts uniformTypeIdentifiers.
expect(listEquals(config.utis, <String>['public.text', 'public.image']),
isTrue);
expect(config.allowMultiSelection, isFalse);
Expand Down Expand Up @@ -92,14 +92,14 @@ void main() {
label: 'text',
extensions: <String>['txt'],
mimeTypes: <String>['text/plain'],
macUTIs: <String>['public.text'],
uniformTypeIdentifiers: <String>['public.text'],
);

const XTypeGroup groupTwo = XTypeGroup(
label: 'image',
extensions: <String>['jpg'],
mimeTypes: <String>['image/jpg'],
macUTIs: <String>['public.image'],
uniformTypeIdentifiers: <String>['public.image'],
webWildCards: <String>['image/*']);

await plugin.openFiles(acceptedTypeGroups: <XTypeGroup>[group, groupTwo]);
Expand All @@ -108,7 +108,7 @@ void main() {
final FileSelectorConfig config =
result.captured[0] as FileSelectorConfig;

// iOS only accepts macUTIs.
// iOS only accepts uniformTypeIdentifiers.
expect(listEquals(config.utis, <String>['public.text', 'public.image']),
isTrue);
expect(config.allowMultiSelection, isTrue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,12 @@ void main() {
label: 'text',
extensions: <String>['txt'],
mimeTypes: <String>['text/plain'],
macUTIs: <String>['public.text'],
);

const XTypeGroup groupTwo = XTypeGroup(
label: 'image',
extensions: <String>['jpg'],
mimeTypes: <String>['image/jpg'],
macUTIs: <String>['public.image'],
webWildCards: <String>['image/*'],
);

await plugin.openFile(acceptedTypeGroups: <XTypeGroup>[group, groupTwo]);
Expand Down Expand Up @@ -144,15 +141,12 @@ void main() {
label: 'text',
extensions: <String>['txt'],
mimeTypes: <String>['text/plain'],
macUTIs: <String>['public.text'],
);

const XTypeGroup groupTwo = XTypeGroup(
label: 'image',
extensions: <String>['jpg'],
mimeTypes: <String>['image/jpg'],
macUTIs: <String>['public.image'],
webWildCards: <String>['image/*'],
);

await plugin.openFiles(acceptedTypeGroups: <XTypeGroup>[group, groupTwo]);
Expand Down Expand Up @@ -250,15 +244,12 @@ void main() {
label: 'text',
extensions: <String>['txt'],
mimeTypes: <String>['text/plain'],
macUTIs: <String>['public.text'],
);

const XTypeGroup groupTwo = XTypeGroup(
label: 'image',
extensions: <String>['jpg'],
mimeTypes: <String>['image/jpg'],
macUTIs: <String>['public.image'],
webWildCards: <String>['image/*'],
);

await plugin
Expand Down
4 changes: 4 additions & 0 deletions packages/file_selector/file_selector_macos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.9.0+9

* Updates references to the deprecated `macUTIs`.

## 0.9.0+8

* Updates pigeon for null value handling fixes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ class FileSelectorMacOS extends FileSelectorPlatform {
// Reject a filter that isn't an allow-any, but doesn't set any
// macOS-supported filter categories.
if ((typeGroup.extensions?.isEmpty ?? true) &&
(typeGroup.macUTIs?.isEmpty ?? true) &&
(typeGroup.uniformTypeIdentifiers?.isEmpty ?? true) &&
(typeGroup.mimeTypes?.isEmpty ?? true)) {
throw ArgumentError('Provided type group $typeGroup does not allow '
'all files, but does not set any of the macOS-supported filter '
'categories. At least one of "extensions", "macUTIs", or '
'"mimeTypes" must be non-empty for macOS if anything is '
'non-empty.');
'categories. At least one of "extensions", '
'"uniformTypeIdentifiers", or "mimeTypes" must be non-empty for '
'macOS if anything is non-empty.');
}
allowedTypes.extensions.addAll(typeGroup.extensions ?? <String>[]);
allowedTypes.mimeTypes.addAll(typeGroup.mimeTypes ?? <String>[]);
allowedTypes.utis.addAll(typeGroup.macUTIs ?? <String>[]);
allowedTypes.utis.addAll(typeGroup.uniformTypeIdentifiers ?? <String>[]);
}

return allowedTypes;
Expand Down
4 changes: 2 additions & 2 deletions packages/file_selector/file_selector_macos/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: file_selector_macos
description: macOS implementation of the file_selector plugin.
repository: https://github.com/flutter/packages/tree/main/packages/file_selector/file_selector_macos
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
version: 0.9.0+8
version: 0.9.0+9

environment:
sdk: ">=2.18.0 <4.0.0"
Expand All @@ -18,7 +18,7 @@ flutter:

dependencies:
cross_file: ^0.3.1
file_selector_platform_interface: ^2.2.0
file_selector_platform_interface: ^2.3.0
flutter:
sdk: flutter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ void main() {
label: 'text',
extensions: <String>['txt'],
mimeTypes: <String>['text/plain'],
macUTIs: <String>['public.text'],
uniformTypeIdentifiers: <String>['public.text'],
);

const XTypeGroup groupTwo = XTypeGroup(
label: 'image',
extensions: <String>['jpg'],
mimeTypes: <String>['image/jpg'],
macUTIs: <String>['public.image'],
uniformTypeIdentifiers: <String>['public.image'],
webWildCards: <String>['image/*']);

await plugin.openFile(acceptedTypeGroups: <XTypeGroup>[group, groupTwo]);
Expand Down Expand Up @@ -165,14 +165,14 @@ void main() {
label: 'text',
extensions: <String>['txt'],
mimeTypes: <String>['text/plain'],
macUTIs: <String>['public.text'],
uniformTypeIdentifiers: <String>['public.text'],
);

const XTypeGroup groupTwo = XTypeGroup(
label: 'image',
extensions: <String>['jpg'],
mimeTypes: <String>['image/jpg'],
macUTIs: <String>['public.image'],
uniformTypeIdentifiers: <String>['public.image'],
webWildCards: <String>['image/*']);

await plugin.openFiles(acceptedTypeGroups: <XTypeGroup>[group, groupTwo]);
Expand Down Expand Up @@ -256,14 +256,14 @@ void main() {
label: 'text',
extensions: <String>['txt'],
mimeTypes: <String>['text/plain'],
macUTIs: <String>['public.text'],
uniformTypeIdentifiers: <String>['public.text'],
);

const XTypeGroup groupTwo = XTypeGroup(
label: 'image',
extensions: <String>['jpg'],
mimeTypes: <String>['image/jpg'],
macUTIs: <String>['public.image'],
uniformTypeIdentifiers: <String>['public.image'],
webWildCards: <String>['image/*']);

await plugin
Expand Down Expand Up @@ -372,13 +372,13 @@ void main() {
label: 'text',
extensions: <String>['txt'],
mimeTypes: <String>['text/plain'],
macUTIs: <String>['public.text'],
uniformTypeIdentifiers: <String>['public.text'],
),
const XTypeGroup(
label: 'image',
extensions: <String>['jpg'],
mimeTypes: <String>['image/jpg'],
macUTIs: <String>['public.image'],
uniformTypeIdentifiers: <String>['public.image'],
),
const XTypeGroup(
label: 'any',
Expand Down
2 changes: 1 addition & 1 deletion packages/file_selector/file_selector_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ flutter:
fileName: file_selector_web.dart

dependencies:
file_selector_platform_interface: ^2.2.0
file_selector_platform_interface: ^2.3.0
flutter:
sdk: flutter
flutter_web_plugins:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ void main() {

test('throws for a type group that does not support web', () {
const List<XTypeGroup> acceptedTypes = <XTypeGroup>[
XTypeGroup(label: 'text', macUTIs: <String>['public.text']),
XTypeGroup(
label: 'text', uniformTypeIdentifiers: <String>['public.text']),
];
expect(() => acceptedTypesToString(acceptedTypes), throwsArgumentError);
});
Expand Down
Loading