Recently i have met a lot of questions about a problem with uploading say ‘image to firebase’.
This can be done by putFile()
method.
according to asynchronous programming concept if the async method returns a value, that value must be in the future.
this putFile()
method is returning an UploadTask
object to give you a control on the upload process.
How it returns just UploadTask
rather than Future<UploadTask>
if it’s necessary to await
for it when uploading the file.
Example to get the view:
// i don't need any control on the upload process, just upload the image
await putFile(file); // works
Note: Removing await will not upload the image.
While:
// i need to control the upload process
UploadTask ut = putFile(file); // works
Got it, how it can return a value not in the future, while just uploading a file requires await
.
I read a bit, the problem not revolving around when or whether the upload task begins or not
Questions that represents that problem: 1 , 2