The onTap waits for the pics and docs to get uploaded then it pops the page. but I want it to show a cicularProgressIndicator on top of everything and the user gets a message to wait until the onTap is finished.
onTap: () async {
if (image11 != null) {
await uploadImage1(image11);
}
await firestor.add({
"Doc": docs.text,
"gear": gear.text,
"price": price.text,
"1stpic": imageUrl1,
});
await Navigator.pop(context);
},
CodePudding user response:
onTap: () async {
openloadingdialog(context);
if (image11 != null) {
await uploadImage1(image11);
}
await firestor.add({
"Doc": docs.text,
"gear": gear.text,
"price": price.text,
"1stpic": imageUrl1,
});
Navigator.pop(context);
await Navigator.pop(context);
},
openloadingdialog(BuildContext context) {
showDialog(
barrierDismissible: false,
useRootNavigator: false,
context: context,
builder: (BuildContext context) {
return WillPopScope(
onWillPop: () async {
return false;
},
child: AlertDialog(
backgroundColor: Theme.of(context).canvasColor,
content: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
width: 50,
height: 50,
child: CircularProgressIndicator(),
),
],
),
)
);
},
);
}