Repository navigation
Open
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterp: file_selectorThe file_selector pluginThe file_selector pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyAndroid applications specificallyteam-androidOwned by Android platform teamOwned by Android platform teamtriaged-androidTriaged by Android platform teamTriaged by Android platform team
Description
Use case
Calling getSavePath in Android should return a storage path for the user to save a file of any type in there.
The following is an example of use, without managing permissions or exceptions, to show how a really happy path would look.
// other imports
import 'package:file_selector_platform_interface/file_selector_platform_interface.dart';
class X {
// other functions
Future<void> _saveFile() async {
final String? savePath = await FileSelectorPlatform.instance.getSavePath(
suggestedName: 'somefile.txt',
);
final String text = 'Example text';
final Uint8List fileData = Uint8List.fromList(text.codeUnits);
const String fileMimeType = 'text/plain';
final XFile textFile =
XFile.fromData(fileData, mimeType: fileMimeType, name: fileName);
await textFile.saveTo(path);
}
}Proposal
As discussed in the PR #6547, we're leaving behind the Android implementation for getSavePath due to the fundamental working differences with the other platforms.
The proposal is to add the implementation for getSavePath to the Android platform and discuss the best approach.
You can follow the discussion that triggered this issue here.
And we have a draft PR with an implementation here.
This should be implemented after the Android implementation for
file_selectoris 'live'.
Reacted by Yegor Pelykh, Roman Zaynetdinov, Gabriel Terwesten, ninhngadev, Brady Trainor, adywizard, K. P. Krasiński-Sroka, CodeDoctor, August, existedinnettw and 3 more
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterp: file_selectorThe file_selector pluginThe file_selector pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyAndroid applications specificallyteam-androidOwned by Android platform teamOwned by Android platform teamtriaged-androidTriaged by Android platform teamTriaged by Android platform team
Activity
yegor-pelykh commentedon Apr 11, 2023
epw commentedon Dec 10, 2024
This would be helpful for me. I am writing an app which serializes its state to a file that the user should be free to interact with through their filesystem (for example, picking a file in a Dropbox folder, so it will be automatically copied to other devices with other platforms). As far as I can tell,
getSaveLocation()would implement exactly the interface I want to present to the user: an OS-native file picker that does not require excess permissions. Please consider adding Android support!