Skip to content
Open
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.1.0

* Adds `canCreateDirectories` param to `getSaveLocation`, `getDirectoryPath` and `getDirectoryPaths` to control whether users can create directories during location selection.

## 1.0.4

* Updates the example app and README examples to work on iOS.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
platform :osx, '10.14'
platform :osx, '10.15'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
33CC10EB2044A3C60003C045 /* Resources */,
33CC110E2044A8840003C045 /* Bundle Framework */,
3399D490228B24CF009A79C7 /* ShellScript */,
43898F02A8C2312B24AEE41B /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -299,6 +300,23 @@
shellPath = /bin/sh;
shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire";
};
43898F02A8C2312B24AEE41B /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
A778864BDDD7B12C41D66FBB /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -395,7 +413,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down Expand Up @@ -474,7 +492,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -521,7 +539,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down
4 changes: 4 additions & 0 deletions packages/file_selector/file_selector/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ dev_dependencies:

flutter:
uses-material-design: true
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
file_selector_platform_interface: {path: ../../../../packages/file_selector/file_selector_platform_interface}
34 changes: 28 additions & 6 deletions packages/file_selector/file_selector/lib/file_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,25 @@ Future<List<XFile>> openFiles({
/// [confirmButtonText] is the text in the confirmation button of the dialog.
/// When not provided, the default OS label is used (for example, "Save").
///
/// [canCreateDirectories] controls whether the user is allowed to create new
/// directories in the save dialog. When not provided, uses the platform default.
/// May not be supported on all platforms.
///
/// Returns `null` if the user cancels the operation.
Future<FileSaveLocation?> getSaveLocation({
List<XTypeGroup> acceptedTypeGroups = const <XTypeGroup>[],
String? initialDirectory,
String? suggestedName,
String? confirmButtonText,
bool? canCreateDirectories,
}) async {
return FileSelectorPlatform.instance.getSaveLocation(
acceptedTypeGroups: acceptedTypeGroups,
options: SaveDialogOptions(
initialDirectory: initialDirectory,
suggestedName: suggestedName,
confirmButtonText: confirmButtonText,
canCreateDirectories: canCreateDirectories,
),
);
}
Expand All @@ -121,14 +127,22 @@ Future<FileSaveLocation?> getSaveLocation({
/// [confirmButtonText] is the text in the confirmation button of the dialog.
/// When not provided, the default OS label is used (for example, "Open").
///
/// [canCreateDirectories] controls whether the user is allowed to create new
/// directories in the dialog. When not provided, uses the platform default.
/// May not be supported on all platforms.
///
/// Returns `null` if the user cancels the operation.
Future<String?> getDirectoryPath({
String? initialDirectory,
String? confirmButtonText,
bool? canCreateDirectories,
}) async {
return FileSelectorPlatform.instance.getDirectoryPath(
initialDirectory: initialDirectory,
confirmButtonText: confirmButtonText,
return FileSelectorPlatform.instance.getDirectoryPathWithOptions(
FileDialogOptions(
initialDirectory: initialDirectory,
confirmButtonText: confirmButtonText,
canCreateDirectories: canCreateDirectories,
),
);
}

Expand All @@ -144,13 +158,21 @@ Future<String?> getDirectoryPath({
/// [confirmButtonText] is the text in the confirmation button of the dialog.
/// When not provided, the default OS label is used (for example, "Open").
///
/// [canCreateDirectories] controls whether the user is allowed to create new
/// directories in the dialog. When not provided, uses the platform default.
/// May not be supported on all platforms.
///
/// Returns an empty array if the user cancels the operation.
Future<List<String?>> getDirectoryPaths({
String? initialDirectory,
String? confirmButtonText,
bool? canCreateDirectories,
}) async {
return FileSelectorPlatform.instance.getDirectoryPaths(
initialDirectory: initialDirectory,
confirmButtonText: confirmButtonText,
return FileSelectorPlatform.instance.getDirectoryPathsWithOptions(
FileDialogOptions(
initialDirectory: initialDirectory,
confirmButtonText: confirmButtonText,
canCreateDirectories: canCreateDirectories,
),
);
}
6 changes: 5 additions & 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: 1.0.4
version: 1.1.0

environment:
sdk: ^3.7.0
Expand Down Expand Up @@ -46,3 +46,7 @@ topics:
- files
- file-selection
- file-selector
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
file_selector_platform_interface: {path: ../../../packages/file_selector/file_selector_platform_interface}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ void main() {
const String initialDirectory = '/home/flutteruser';
const String confirmButtonText = 'Use this profile picture';
const String suggestedName = 'suggested_name';

const List<XTypeGroup> acceptedTypeGroups = <XTypeGroup>[
XTypeGroup(
label: 'documents',
Expand Down Expand Up @@ -227,6 +228,18 @@ void main() {
);
expect(location?.path, expectedSavePath);
});

test('sets the directory creation control flag', () async {
const bool canCreateDirectories = false;
fakePlatformImplementation
..setExpectations(canCreateDirectories: canCreateDirectories)
..setPathsResponse(<String>[expectedSavePath]);

final FileSaveLocation? location = await getSaveLocation(
canCreateDirectories: canCreateDirectories,
);
expect(location?.path, expectedSavePath);
});
});

group('getDirectoryPath', () {
Expand Down Expand Up @@ -278,6 +291,18 @@ void main() {
);
expect(directoryPath, expectedDirectoryPath);
});

test('sets the directory creation control flag', () async {
const bool canCreateDirectories = true;
fakePlatformImplementation
..setExpectations(canCreateDirectories: canCreateDirectories)
..setPathsResponse(<String>[expectedDirectoryPath]);

final String? directoryPath = await getDirectoryPath(
canCreateDirectories: canCreateDirectories,
);
expect(directoryPath, expectedDirectoryPath);
});
});

group('getDirectoryPaths', () {
Expand Down Expand Up @@ -330,6 +355,17 @@ void main() {
);
expect(directoryPaths, expectedDirectoryPaths);
});
test('sets the directory creation control flag', () async {
const bool canCreateDirectories = true;
fakePlatformImplementation
..setExpectations(canCreateDirectories: canCreateDirectories)
..setPathsResponse(expectedDirectoryPaths);

final List<String?> directoryPaths = await getDirectoryPaths(
canCreateDirectories: canCreateDirectories,
);
expect(directoryPaths, expectedDirectoryPaths);
});
});
}

Expand All @@ -341,6 +377,7 @@ class FakeFileSelector extends Fake
String? initialDirectory;
String? confirmButtonText;
String? suggestedName;
bool? canCreateDirectories;
// Return values.
List<XFile>? files;
List<String>? paths;
Expand All @@ -351,11 +388,13 @@ class FakeFileSelector extends Fake
String? initialDirectory,
String? suggestedName,
String? confirmButtonText,
bool? canCreateDirectories,
}) {
this.acceptedTypeGroups = acceptedTypeGroups;
this.initialDirectory = initialDirectory;
this.suggestedName = suggestedName;
this.confirmButtonText = confirmButtonText;
this.canCreateDirectories = canCreateDirectories;
}

// ignore: use_setters_to_change_properties
Expand Down Expand Up @@ -436,19 +475,41 @@ class FakeFileSelector extends Fake
Future<String?> getDirectoryPath({
String? initialDirectory,
String? confirmButtonText,
bool canCreateDirectories = true,
}) async {
expect(initialDirectory, this.initialDirectory);
expect(confirmButtonText, this.confirmButtonText);
expect(canCreateDirectories, this.canCreateDirectories);
return paths?[0];
}

@override
Future<String?> getDirectoryPathWithOptions(FileDialogOptions options) async {
expect(options.initialDirectory, initialDirectory);
expect(options.confirmButtonText, confirmButtonText);
expect(options.canCreateDirectories, canCreateDirectories);
return paths?[0];
}

@override
Future<List<String>> getDirectoryPaths({
String? initialDirectory,
String? confirmButtonText,
bool canCreateDirectories = true,
}) async {
expect(initialDirectory, this.initialDirectory);
expect(confirmButtonText, this.confirmButtonText);
expect(canCreateDirectories, this.canCreateDirectories);
return paths!;
}

@override
Future<List<String>> getDirectoryPathsWithOptions(
FileDialogOptions options,
) async {
expect(options.initialDirectory, initialDirectory);
expect(options.confirmButtonText, confirmButtonText);
expect(options.canCreateDirectories, canCreateDirectories);
return paths!;
}
}
4 changes: 4 additions & 0 deletions packages/file_selector/file_selector_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.3

* Adds `getDirectoryPathWithOptions` and `getDirectoryPathsWithOptions` implementations.

## 0.5.2+1

* Resolves Gradle 9 deprecations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ dev_dependencies:

flutter:
uses-material-design: true
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
file_selector_platform_interface: {path: ../../../../packages/file_selector/file_selector_platform_interface}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ class FileSelectorAndroid extends FileSelectorPlatform {
String? initialDirectory,
String? confirmButtonText,
}) async {
return _api.getDirectoryPath(initialDirectory);
return getDirectoryPathWithOptions(
FileDialogOptions(initialDirectory: initialDirectory),
);
}

@override
Future<String?> getDirectoryPathWithOptions(FileDialogOptions options) async {
return _api.getDirectoryPath(options.initialDirectory);
}

XFile _xFileFromFileResponse(FileResponse file) {
Expand Down
6 changes: 5 additions & 1 deletion packages/file_selector/file_selector_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: file_selector_android
description: Android implementation of the file_selector package.
repository: https://github.com/flutter/packages/tree/main/packages/file_selector/file_selector_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
version: 0.5.2+1
version: 0.5.3

environment:
sdk: ^3.9.0
Expand Down Expand Up @@ -34,3 +34,7 @@ topics:
- files
- file-selection
- file-selector
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
file_selector_platform_interface: {path: ../../../packages/file_selector/file_selector_platform_interface}
3 changes: 2 additions & 1 deletion packages/file_selector/file_selector_linux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 0.9.4

* Adds `getDirectoryPathWithOptions` and `getDirectoryPathsWithOptions` implementations.
* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.

## 0.9.3+2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ dev_dependencies:

flutter:
uses-material-design: true
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
file_selector_platform_interface: {path: ../../../../packages/file_selector/file_selector_platform_interface}
Loading