Skip to content

Commit

Permalink
[file_selector] Return a non-null value from getSavePath on web (flut…
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartmorgan authored Feb 25, 2021
1 parent 8201637 commit 494e9f9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/file_selector/file_selector_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.8.1

- Return a non-null value from `getSavePath` for consistency with
API expectations that null indicates canceling.

# 0.8.0

- Migrated to null-safety
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ void main() {
expect(await files[1].lastModified(), isNotNull);
});
});

group('getSavePath', () {
testWidgets('returns non-null', (WidgetTester _) async {
final plugin = FileSelectorWeb();
final savePath = plugin.getSavePath();
expect(await savePath, isNotNull);
});
});
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,17 @@ class FileSelectorWeb extends FileSelectorPlatform {
return _openFiles(acceptedTypeGroups: acceptedTypeGroups, multiple: true);
}

// This is intended to be passed to XFile, which ignores the path, but 'null'
// indicates a canceled save on other platforms, so provide a non-null dummy
// value.
@override
Future<String?> getSavePath({
List<XTypeGroup>? acceptedTypeGroups,
String? initialDirectory,
String? suggestedName,
String? confirmButtonText,
}) async =>
null;
'';

@override
Future<String?> getDirectoryPath({
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
@@ -1,7 +1,7 @@
name: file_selector_web
description: Web platform implementation of file_selector
homepage: https://github.com/flutter/plugins/tree/master/packages/file_selector/file_selector_web
version: 0.8.0
version: 0.8.1

flutter:
plugin:
Expand Down

0 comments on commit 494e9f9

Please sign in to comment.