Issue
onPressed: () => {
popUpForGroup("Add Group", null, context),
print("pop up closed"),
refreshPage(),
},
Here all three functions run at the same time.
I want to execute the refreshPage() function only when the popUpForGroup() execution ends.
popUpForGroup() is a function from another file, it displays a Dialogue box for adding a group to the database, and I wanted to refresh my current file( where I call the onpressed function)
Solution
Transform your popUpForGroup to async function like this.
Future<void> popUpForGroup({...}) {...}
After that and inside your onPressed Function you can write this:
onPressed: () async => {
await popUpForGroup("Add Group", null, context),
print("pop up closed"),
refreshPage(),
},
Answered By – Felipe Vergara
Answer Checked By – Jay B. (BugsFixing Admin)