Skip to content

[file_selector] Update to 1.0 #4362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 6, 2023
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
4 changes: 4 additions & 0 deletions packages/file_selector/file_selector/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.0

* Removes the deprecated `getSavePath` in favor of `getSaveLocation`.

## 0.9.5

* Adds an endorsed Android implementation.
Expand Down
36 changes: 0 additions & 36 deletions packages/file_selector/file_selector/lib/file_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,42 +71,6 @@ Future<List<XFile>> openFiles({
confirmButtonText: confirmButtonText);
}

/// Opens a save dialog and returns the target path chosen by the user.
///
/// [acceptedTypeGroups] is a list of file type groups that can be selected in
/// the dialog. How this is displayed depends on the pltaform, for example:
/// - On Windows and Linux, each group will be an entry in a list of filter
/// options.
/// - On macOS, the union of all types allowed by all of the groups will be
/// allowed.
/// Throws an [ArgumentError] if any type groups do not include filters
/// supported by the current platform.
///
/// [initialDirectory] is the full path to the directory that will be displayed
/// when the dialog is opened. When not provided, the platform will pick an
/// initial location.
///
/// [suggestedName] is initial value of file name.
///
/// [confirmButtonText] is the text in the confirmation button of the dialog.
/// When not provided, the default OS label is used (for example, "Save").
///
/// Returns `null` if the user cancels the operation.
@Deprecated('Use getSaveLocation instead')
Future<String?> getSavePath({
List<XTypeGroup> acceptedTypeGroups = const <XTypeGroup>[],
String? initialDirectory,
String? suggestedName,
String? confirmButtonText,
}) async {
return (await getSaveLocation(
acceptedTypeGroups: acceptedTypeGroups,
initialDirectory: initialDirectory,
suggestedName: suggestedName,
confirmButtonText: confirmButtonText))
?.path;
}

/// Opens a save dialog and returns the target path chosen by the user.
///
/// [acceptedTypeGroups] is a list of file type groups that can be selected in
Expand Down
2 changes: 1 addition & 1 deletion packages/file_selector/file_selector/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for opening and saving files, or selecting
directories, using native file selection UI.
repository: https://github.com/flutter/packages/tree/main/packages/file_selector/file_selector
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
version: 0.9.5
version: 1.0.0

environment:
sdk: ">=2.18.0 <4.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,75 +217,6 @@ void main() {
});
});

group('getSavePath (deprecated)', () {
const String expectedSavePath = '/example/path';

test('works', () async {
fakePlatformImplementation
..setExpectations(
initialDirectory: initialDirectory,
confirmButtonText: confirmButtonText,
acceptedTypeGroups: acceptedTypeGroups,
suggestedName: suggestedName)
..setPathsResponse(<String>[expectedSavePath]);

final String? savePath = await getSavePath(
initialDirectory: initialDirectory,
confirmButtonText: confirmButtonText,
acceptedTypeGroups: acceptedTypeGroups,
suggestedName: suggestedName,
);

expect(savePath, expectedSavePath);
});

test('works with no arguments', () async {
fakePlatformImplementation.setPathsResponse(<String>[expectedSavePath]);

final String? savePath = await getSavePath();
expect(savePath, expectedSavePath);
});

test('sets the initial directory', () async {
fakePlatformImplementation
..setExpectations(initialDirectory: initialDirectory)
..setPathsResponse(<String>[expectedSavePath]);

final String? savePath =
await getSavePath(initialDirectory: initialDirectory);
expect(savePath, expectedSavePath);
});

test('sets the button confirmation label', () async {
fakePlatformImplementation
..setExpectations(confirmButtonText: confirmButtonText)
..setPathsResponse(<String>[expectedSavePath]);

final String? savePath =
await getSavePath(confirmButtonText: confirmButtonText);
expect(savePath, expectedSavePath);
});

test('sets the accepted type groups', () async {
fakePlatformImplementation
..setExpectations(acceptedTypeGroups: acceptedTypeGroups)
..setPathsResponse(<String>[expectedSavePath]);

final String? savePath =
await getSavePath(acceptedTypeGroups: acceptedTypeGroups);
expect(savePath, expectedSavePath);
});

test('sets the suggested name', () async {
fakePlatformImplementation
..setExpectations(suggestedName: suggestedName)
..setPathsResponse(<String>[expectedSavePath]);

final String? savePath = await getSavePath(suggestedName: suggestedName);
expect(savePath, expectedSavePath);
});
});

group('getDirectoryPath', () {
const String expectedDirectoryPath = '/example/path';

Expand Down