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

Commit 67be46c

Browse files
committed
apply feedback
1 parent 7bee03c commit 67be46c

File tree

6 files changed

+78
-73
lines changed

6 files changed

+78
-73
lines changed

packages/file_selector/file_selector_platform_interface/CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
## 2.3.0+1
1+
## 2.4.0
2+
3+
* Adds `getDirectoryPaths` method to the interface.
4+
5+
## 2.3.0
26

3-
* Adds `getDirectoriesPaths` method to the interface.
47
* Replaces `macUTIs` with `uniformTypeIdentifiers`. `macUTIs` is available as an alias, but will be deprecated in a future release.
58

69
## 2.2.0

packages/file_selector/file_selector_platform_interface/lib/src/method_channel/method_channel_file_selector.dart

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class MethodChannelFileSelector extends FileSelectorPlatform {
1616
@visibleForTesting
1717
MethodChannel get channel => _channel;
1818

19-
/// Load a file from user's computer and return it as an XFile
2019
@override
2120
Future<XFile?> openFile({
2221
List<XTypeGroup>? acceptedTypeGroups,
@@ -37,7 +36,6 @@ class MethodChannelFileSelector extends FileSelectorPlatform {
3736
return path == null ? null : XFile(path.first);
3837
}
3938

40-
/// Load multiple files from user's computer and return it as an XFile
4139
@override
4240
Future<List<XFile>> openFiles({
4341
List<XTypeGroup>? acceptedTypeGroups,
@@ -58,7 +56,6 @@ class MethodChannelFileSelector extends FileSelectorPlatform {
5856
return pathList?.map((String path) => XFile(path)).toList() ?? <XFile>[];
5957
}
6058

61-
/// Gets the path from a save dialog
6259
@override
6360
Future<String?> getSavePath({
6461
List<XTypeGroup>? acceptedTypeGroups,
@@ -79,7 +76,6 @@ class MethodChannelFileSelector extends FileSelectorPlatform {
7976
);
8077
}
8178

82-
/// Gets a directory path from a dialog
8379
@override
8480
Future<String?> getDirectoryPath({
8581
String? initialDirectory,
@@ -94,17 +90,16 @@ class MethodChannelFileSelector extends FileSelectorPlatform {
9490
);
9591
}
9692

97-
/// Gets a list of directories paths from a dialog
9893
@override
99-
Future<List<String>?> getDirectoriesPaths(
94+
Future<List<String>> getDirectoryPaths(
10095
{String? initialDirectory, String? confirmButtonText}) async {
101-
return _channel.invokeListMethod<String>(
102-
'getDirectoriesPaths',
96+
final List<String>? pathList = await _channel.invokeListMethod<String>(
97+
'getDirectoryPaths',
10398
<String, dynamic>{
10499
'initialDirectory': initialDirectory,
105100
'confirmButtonText': confirmButtonText,
106-
'multiple': true,
107101
},
108102
);
103+
return pathList ?? <String>[];
109104
}
110105
}

packages/file_selector/file_selector_platform_interface/lib/src/platform_interface/file_selector_interface.dart

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ abstract class FileSelectorPlatform extends PlatformInterface {
3636
_instance = instance;
3737
}
3838

39-
/// Open file dialog for loading files and return a file path
39+
/// Opens a file dialog for loading files and returns a file path.
4040
/// Returns `null` if user cancels the operation.
4141
Future<XFile?> openFile({
4242
List<XTypeGroup>? acceptedTypeGroups,
@@ -46,7 +46,7 @@ abstract class FileSelectorPlatform extends PlatformInterface {
4646
throw UnimplementedError('openFile() has not been implemented.');
4747
}
4848

49-
/// Open file dialog for loading files and return a list of file paths
49+
/// Opens a file dialog for loading files and returns a list of file paths.
5050
Future<List<XFile>> openFiles({
5151
List<XTypeGroup>? acceptedTypeGroups,
5252
String? initialDirectory,
@@ -55,7 +55,7 @@ abstract class FileSelectorPlatform extends PlatformInterface {
5555
throw UnimplementedError('openFiles() has not been implemented.');
5656
}
5757

58-
/// Open file dialog for saving files and return a file path at which to save
58+
/// Opens a file dialog for saving files and returns a file path at which to save.
5959
/// Returns `null` if user cancels the operation.
6060
Future<String?> getSavePath({
6161
List<XTypeGroup>? acceptedTypeGroups,
@@ -66,7 +66,7 @@ abstract class FileSelectorPlatform extends PlatformInterface {
6666
throw UnimplementedError('getSavePath() has not been implemented.');
6767
}
6868

69-
/// Open file dialog for loading directories and return a directory path
69+
/// Opens a file dialog for loading directories and returns a directory path.
7070
/// Returns `null` if user cancels the operation.
7171
Future<String?> getDirectoryPath({
7272
String? initialDirectory,
@@ -75,12 +75,11 @@ abstract class FileSelectorPlatform extends PlatformInterface {
7575
throw UnimplementedError('getDirectoryPath() has not been implemented.');
7676
}
7777

78-
/// Open file dialog for loading directories and return multiple directories paths
79-
/// Returns `null` if user cancels the operation.
80-
Future<List<String>?> getDirectoriesPaths({
78+
/// Opens a file dialog for loading directories and returns multiple directory paths.
79+
Future<List<String>> getDirectoryPaths({
8180
String? initialDirectory,
8281
String? confirmButtonText,
8382
}) {
84-
throw UnimplementedError('getDirectoriesPaths() has not been implemented.');
83+
throw UnimplementedError('getDirectoryPaths() has not been implemented.');
8584
}
8685
}

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.3.0+1
7+
version: 2.4.0
88

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

packages/file_selector/file_selector_platform_interface/test/file_selector_platform_interface_test.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ void main() {
1919
FileSelectorPlatform.instance = ExtendsFileSelectorPlatform();
2020
});
2121
});
22+
23+
group('#GetDirectoryPaths', () {
24+
test('Should throw unimplemented exception', () async {
25+
final FileSelectorPlatform sut = ExtendsFileSelectorPlatform();
26+
27+
await expectLater(() async {
28+
return sut.getDirectoryPaths();
29+
}, throwsA(isA<UnimplementedError>()));
30+
});
31+
});
2232
}
2333

2434
class ExtendsFileSelectorPlatform extends FileSelectorPlatform {}

packages/file_selector/file_selector_platform_interface/test/method_channel_file_selector_test.dart

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -219,64 +219,62 @@ void main() {
219219
],
220220
);
221221
});
222-
group('#getDirectoryPath', () {
223-
test('passes initialDirectory correctly', () async {
224-
await plugin.getDirectoryPath(initialDirectory: '/example/directory');
222+
});
223+
group('#getDirectoryPath', () {
224+
test('passes initialDirectory correctly', () async {
225+
await plugin.getDirectoryPath(initialDirectory: '/example/directory');
225226

226-
expect(
227-
log,
228-
<Matcher>[
229-
isMethodCall('getDirectoryPath', arguments: <String, dynamic>{
230-
'initialDirectory': '/example/directory',
231-
'confirmButtonText': null,
232-
}),
233-
],
234-
);
235-
});
236-
test('passes confirmButtonText correctly', () async {
237-
await plugin.getDirectoryPath(confirmButtonText: 'Open File');
227+
expect(
228+
log,
229+
<Matcher>[
230+
isMethodCall('getDirectoryPath', arguments: <String, dynamic>{
231+
'initialDirectory': '/example/directory',
232+
'confirmButtonText': null,
233+
}),
234+
],
235+
);
236+
});
237+
test('passes confirmButtonText correctly', () async {
238+
await plugin.getDirectoryPath(confirmButtonText: 'Select Folder');
238239

239-
expect(
240-
log,
241-
<Matcher>[
242-
isMethodCall('getDirectoryPath', arguments: <String, dynamic>{
243-
'initialDirectory': null,
244-
'confirmButtonText': 'Open File',
245-
}),
246-
],
247-
);
248-
});
240+
expect(
241+
log,
242+
<Matcher>[
243+
isMethodCall('getDirectoryPath', arguments: <String, dynamic>{
244+
'initialDirectory': null,
245+
'confirmButtonText': 'Select Folder',
246+
}),
247+
],
248+
);
249249
});
250-
group('#getDirectoriesPaths', () {
251-
test('passes initialDirectory correctly', () async {
252-
await plugin.getDirectoriesPaths(
253-
initialDirectory: '/example/directory');
250+
});
251+
group('#getDirectoryPaths', () {
252+
test('passes initialDirectory correctly', () async {
253+
await plugin.getDirectoryPaths(initialDirectory: '/example/directory');
254254

255-
expect(
256-
log,
257-
<Matcher>[
258-
isMethodCall('getDirectoriesPaths', arguments: <String, dynamic>{
259-
'initialDirectory': '/example/directory',
260-
'confirmButtonText': null,
261-
'multiple': true
262-
}),
263-
],
264-
);
265-
});
266-
test('passes confirmButtonText correctly', () async {
267-
await plugin.getDirectoriesPaths(confirmButtonText: 'Open File');
255+
expect(
256+
log,
257+
<Matcher>[
258+
isMethodCall('getDirectoryPaths', arguments: <String, dynamic>{
259+
'initialDirectory': '/example/directory',
260+
'confirmButtonText': null,
261+
}),
262+
],
263+
);
264+
});
265+
test('passes confirmButtonText correctly', () async {
266+
await plugin.getDirectoryPaths(
267+
confirmButtonText: 'Select one or more Folders');
268268

269-
expect(
270-
log,
271-
<Matcher>[
272-
isMethodCall('getDirectoriesPaths', arguments: <String, dynamic>{
273-
'initialDirectory': null,
274-
'confirmButtonText': 'Open File',
275-
'multiple': true
276-
}),
277-
],
278-
);
279-
});
269+
expect(
270+
log,
271+
<Matcher>[
272+
isMethodCall('getDirectoryPaths', arguments: <String, dynamic>{
273+
'initialDirectory': null,
274+
'confirmButtonText': 'Select one or more Folders',
275+
}),
276+
],
277+
);
280278
});
281279
});
282280
});

0 commit comments

Comments
 (0)