Future<String> uploadFile(String filePath) async {
File file = File(filePath);
final fileName = basename(filePath);
try {
firebase_storage.TaskSnapshot taskSnapshot = await firebase_storage.FirebaseStorage.instance
.ref("news/$fileName")
.putFile(file);
await taskSnapshot.ref.getDownloadURL().then(
(value) {
print("Done: $value");
return value;
}
);
return "123";
} on firebase_core.FirebaseException catch (e) {
print(e);
return "#";
}
}
uploadFile returns me 123 since the value is get printed after that, How do I return value from this function before returning "123"??
return await taskSnapshot.ref....and of course removereturn "123";