I'm trying to implement some file management in my desktop ( windows ) flutter project, so I added the file_picker package from pub.dev, see the link here : https://pub.dev/packages/file_picker.
Following the official documentation, I first tried to add the logic in a separate function to try it before plug the system to my app, see my code below:
testFilePicker() async {
String? savePathFile = await FilePicker.platform.saveFile(
dialogTitle: 'Select a location to save your file',
fileName: "test_file");
}
This piece of code is suppose to open a window where I could choose a path to save a file.
Here comes my problem : my ide (vscode) highlights "platform" as a critical error, see the error message below :
The name 'platform' is being referenced through the prefix 'FilePicker', but it isn't defined in any of the libraries imported using that prefix.
Of course, I did import file_picker package and prefix it as "FilePicker", this way :
import 'package:file_picker/file_picker.dart' as FilePicker;
So the problem musn't be there, I also tried to uninstall pacakge and re-import it but the problem persists.
I am currently stuck on this and I can't find any solution, any help would be appreciate.
Thanks you in advance.
Rather than importing with
as FilePicker;, import the library without a prefix.Alternatively, you could use a prefix like so:
Full code example: