在我的项目中,我想使用提供程序库。在我的页面中,我有一个图标的网格列表,当用户单击每个图标时,我将显示一个对话框。
在我的对话框中,我有文本字段和一个按钮小部件。当用户填写“文本字段”并单击按钮时,我想从Web服务中获取一些数据,并且获取后,我想在页面的其他“警告”对话框中再次显示这些数据。
我如何处理提供商的这种情况?
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
},
);
});
}
答案 0 :(得分:1)
尝试
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.
}),
}