Reputation: 39
How can I get data from outside? I want to transfer files from phone storage to app. but I couldn't find an example of that.
Upvotes: 0
Views: 189
Reputation: 2087
have you tried file picker?
Its usage seems simple:
FilePickerResult? result = await FilePicker.platform.pickFiles();
if(result != null) {
File file = File(result.files.single.path);
} else {
// User canceled the picker
}
Also, it has null safety support + a good rating on pub.dev
EDIT. One more example for you, here it comes:
FilePickerResult? result = await FilePicker.platform.pickFiles();
if(result != null) {
PlatformFile file = result.files.first;
print(file.name);
print(file.bytes);
print(file.size);
print(file.extension);
print(file.path);
} else {
// User canceled the picker
}
I hope this helps.
Upvotes: 1