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

[file-selector] Update iOS example to use the proper properties when filtering files. #6453

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 0.5.0+2

* Removes the unnecessary `label` and `extensions` parameters for the `_openTextFile`, `_openImageFile` and `_openImageFile`(for multiple images) mehtods.
* Updates minimum Flutter version to 2.10.

## 0.5.0+1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class OpenImagePage extends StatelessWidget {

Future<void> _openImageFile(BuildContext context) async {
final XTypeGroup typeGroup = XTypeGroup(
label: 'images',
extensions: <String>['jpg', 'png'],
macUTIs: <String>['public.image'],
);
final XFile? file = await FileSelectorPlatform.instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@ class OpenMultipleImagesPage extends StatelessWidget {

Future<void> _openImageFile(BuildContext context) async {
final XTypeGroup jpgsTypeGroup = XTypeGroup(
label: 'JPEGs',
extensions: <String>['jpg', 'jpeg'],
macUTIs: <String>['public.jpeg'],
);
final XTypeGroup pngTypeGroup = XTypeGroup(
label: 'PNGs',
extensions: <String>['png'],
macUTIs: <String>['public.png'],
);
final List<XFile> files = await FileSelectorPlatform.instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ class OpenTextPage extends StatelessWidget {

Future<void> _openTextFile(BuildContext context) async {
final XTypeGroup typeGroup = XTypeGroup(
label: 'text',
extensions: <String>['txt', 'json'],
macUTIs: <String>['public.text'],
);
final XFile? file = await FileSelectorPlatform.instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ class FileSelectorIOS extends FileSelectorPlatform {
if (typeGroup.allowsAny) {
return <String>[];
}

if (typeGroup.macUTIs?.isEmpty ?? true) {
throw ArgumentError('The provided type group $typeGroup should either '
'allow all files, or have a non-empty "macUTIs"');
}

allowedUTIs.addAll(typeGroup.macUTIs!);
}
return allowedUTIs;
Expand Down
3 changes: 1 addition & 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/plugins/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.0+1
version: 0.5.0+2

environment:
sdk: ">=2.14.4 <3.0.0"
Expand All @@ -27,4 +27,3 @@ dev_dependencies:
sdk: flutter
mockito: ^5.1.0
pigeon: ^3.2.5