when I use Get.dialog() to show a dialog, then I use Get.back() back dialog, at the same time ,the page widget's getxController operator onClose(), how to solve this problem.
the page structure as follow: mainPage with bottomNavigationBar and the PageView with other page, I use Get.dialog() show a dialog in mainpPage OnReady(), when dialog dismiss, the widget's getxController of other page operators onClose() override function, how to solve this problem.
I use showDialog() show a dialog, when dialog dismiss,widget's getxController will not be closed;
I also experienced this problem when upgrading Flutter 3.16.3 • channel stable and Flutter 3.16.4 • channel stable and couldn't find a solution
In the following figure code, I put Get.close(1); Change to Navigator.of(context).pop(); Can solve the problem
But the onCancel method in Get.defaultDialog is a little tricky to handle
String tips = '确认删除吗?删除后不可恢复。'.tr;
n.showDialog(
context: Get.context!,
builder: (context) => n.Alert()
..content = SizedBox(
height: 40,
child: Center(child: Text(tips)),
)
..actions = [
n.Button('取消'.tr.n)
..style = n.NikuButtonStyle(
foregroundColor:
AppColors.ItemOnColor)
..onPressed = () {
Navigator.of(context).pop();
},
n.Button('删除'.tr.n)
..style = n.NikuButtonStyle(
foregroundColor:
AppColors.ItemOnColor)
..onPressed = () async {
Navigator.of(context).pop();
bool res = await logic.remove(
model.feedbackId,
);
if (res) {
state.itemList.removeAt(
state.itemList.indexWhere(
(e) =>
e.feedbackId ==
model.feedbackId),
);
EasyLoading.showSuccess(
'操作成功'.tr);
} else {
EasyLoading.showError(
'操作失败'.tr);
}
},
],
barrierDismissible: true,
);
It happened to me recently, the problem seems to be when you close (Get.back) the dialog, or the sheet when you change the view or in another controller, but doing everything in the same view and controller solved the problem.
me to