Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Migrate iOS to new name
  • Loading branch information
stuartmorgan-g committed May 1, 2023
commit be2382ac25bbf6c1387904183275b9513b03bcee
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
2 changes: 1 addition & 1 deletion packages/file_selector/file_selector_ios/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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