Reputation: 5942
In my project i want to use provider library.In my page i have a grid list of icon,when user clicked on each icon i will show a dialog.
In my dialog i have Text Field and a button widgets. When user fill the Text Field and clicked on a button i want to fetch some data from my web service and after fetching i want to show again these data on other Alert dialog in my page.
How can i handle that situation by provider?
showDialog(
context: context,
builder: (context) {
return myCustomNumberDialog(
headerTitle: :"Send Data",
buttonTitle: "Search Data",
onConfirmClicked: (input) { //a button action when user tap on it, It send request to api
// when data fetched from service show other dialog
},
);
});
}
Upvotes: 1
Views: 719
Reputation: 34250
Try
onConfirmClicked: (input) {
Provider.of<Model>(context, listen: false)
.callMethod().then((response) {
// Based on the the response coming from Provider, decide functionaliy.
Navigator.of(context).pop(); // pop current dialog
// show new dialog from here.
}),
}
Upvotes: 1