Home > Net >  I want that await method will return or update the value first then go to next line in flutter
I want that await method will return or update the value first then go to next line in flutter

Time:04-12

I am using firebase storage to upload image and i need first that image upload to storage and then donwload url set to imageUrl String url. So that i can pass it into api call. But by using await method its skipped that line of code and moves ahead. And URL is updating after api call.

I have attached the code image for best understanding. Await Method

CodePudding user response:

Try this:

await uploadTask.snapshot.ref.getDownloadURL()
.then((value) => setState(() {
  isModifyPhoto = true;
  imageUrl = value;
}));

CodePudding user response:

I did it by making onTap() method async and await uploadprofile() method call. Its working good now.

  • Related