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

Commit 6777bfb

Browse files
author
Juan Angel Dausa
committed
Update file_selector_platform_interface by adding the new property 'uniformTypeIdentifiers' to the XTypeGroup.
1 parent feed66b commit 6777bfb

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

packages/file_selector/file_selector_platform_interface/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 2.1.1
22

3+
* Adds the `uniformTypeIdentifiers` property to the `XTypeGroup` that relies on `macUTIs`. The last will be deprecated for future releases.
34
* Updates minimum Flutter version to 2.10.
45

56
## 2.1.0

packages/file_selector/file_selector_platform_interface/lib/src/types/x_type_group/x_type_group.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class XTypeGroup {
2626
final List<String>? mimeTypes;
2727

2828
/// The UTIs for this group
29-
final List<String>? macUTIs;
29+
List<String>? macUTIs;
3030

3131
/// The web wild cards for this group (ex: image/*, video/*)
3232
final List<String>? webWildCards;
@@ -50,6 +50,14 @@ class XTypeGroup {
5050
(webWildCards?.isEmpty ?? true);
5151
}
5252

53+
/// Returns the list of Uniform Type Identifiers for this group.
54+
List<String>? get uniformTypeIdentifiers => macUTIs;
55+
56+
/// Returns the list of Uniform Type Identifiers for this group.
57+
set uniformTypeIdentifiers(List<String>? value) {
58+
macUTIs = value;
59+
}
60+
5361
static List<String>? _removeLeadingDots(List<String>? exts) => exts
5462
?.map((String ext) => ext.startsWith('.') ? ext.substring(1) : ext)
5563
.toList();

packages/file_selector/file_selector_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repository: https://github.com/flutter/plugins/tree/main/packages/file_selector/
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
55
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
66
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
7-
version: 2.1.0
7+
version: 2.1.1
88

99
environment:
1010
sdk: ">=2.12.0 <3.0.0"

packages/file_selector/file_selector_platform_interface/test/x_type_group_test.dart

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import 'package:flutter_test/flutter_test.dart';
77

88
void main() {
99
group('XTypeGroup', () {
10+
final List<String> extensions = <String>['txt', 'jpg'];
11+
final List<String> mimeTypes = <String>['text/plain'];
12+
final List<String> macUTIs = <String>['public.plain-text'];
13+
final List<String> webWildCards = <String>['image/*'];
14+
1015
test('toJSON() creates correct map', () {
1116
const String label = 'test group';
12-
final List<String> extensions = <String>['txt', 'jpg'];
13-
final List<String> mimeTypes = <String>['text/plain'];
14-
final List<String> macUTIs = <String>['public.plain-text'];
15-
final List<String> webWildCards = <String>['image/*'];
1617

1718
final XTypeGroup group = XTypeGroup(
1819
label: label,
@@ -71,6 +72,24 @@ void main() {
7172
expect(webOnly.allowsAny, false);
7273
});
7374

75+
test('setUniformTypeIdentifiers overrides macUTIs', () {
76+
final XTypeGroup group = XTypeGroup(
77+
label: 'Any',
78+
);
79+
80+
group.uniformTypeIdentifiers = macUTIs;
81+
82+
expect(group.uniformTypeIdentifiers, macUTIs);
83+
});
84+
85+
test('getUniformTypeIdentifiers returns macUTIs', () {
86+
final XTypeGroup group = XTypeGroup(
87+
macUTIs: macUTIs,
88+
);
89+
90+
expect(group.uniformTypeIdentifiers, macUTIs);
91+
});
92+
7493
test('Leading dots are removed from extensions', () {
7594
final List<String> extensions = <String>['.txt', '.jpg'];
7695
final XTypeGroup group = XTypeGroup(extensions: extensions);

0 commit comments

Comments
 (0)