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

[file_selector] Return a non-null value from getSavePath on web #3630

Merged
Merged
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
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