'I want that await method will return or update the value first then go to next line in flutter
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.
Solution 1:[1]
Try this:
await uploadTask.snapshot.ref.getDownloadURL()
.then((value) => setState(() {
isModifyPhoto = true;
imageUrl = value;
}));
Solution 2:[2]
I did it by making onTap() method async and await uploadprofile() method call. Its working good now.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | fsbelinda |
| Solution 2 | Nisha Jain |

