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