Issue
Package tried: https://pub.dev/packages/file_picker
Tried the example code implementation shared via GitHub. But the file path is returned as null
for
web platform. Where same implementation in mobile platform return the path as expected.
Things aware of:
- Path_Provider – Not supported for web
- dart-io-library – Not supported for web
- Open issue in Flutter Repo
Goal is to read the file from the path and not to upload. Any workaround to achieve this will be helpful.
Flutter channel: beta
Solution
As mentioned in the file_picker FAQ:
Paths aren’t inaccessible from browsers since those provide fake paths. If you want to create a File instance to upload it somewhere, like FireStorage, you can do so with the bytes directly.
final result = await FilePicker.platform.pickFiles(type: FileType.any, allowMultiple: false);
if (result.files.first != null){
var fileBytes = result.files.first.bytes;
var fileName = result.files.first.name;
print(String.fromCharCodes(fileBytes));
}
Answered By – Spatz
Answer Checked By – Dawn Plyler (FlutterFixes Volunteer)