Future<Widget> _onBackPress(
BuildContext context, PharmacyProvider pharmacyModel) async {
return await showDialog(
context: context,
barrierDismissible: false,
useRootNavigator: false,
builder: (context) {
return AlertDialog(
title: Text(
"등록 취소",
textAlign: TextAlign.center,
),
content: Text(
"처음화면으로 돌아갑니다.",
style: TextStyle(fontWeight: FontWeight.normal),
textAlign: TextAlign.center,
),
actions: [
TextButton(
child: Text("취소"),
onPressed: () {
OoNavigator.pop(context);
},
),
TextButton(
child: Text("확인"),
onPressed: () {
if (!pharmacyModel.isSaved) {
pharmacyModel.selectedPharmacy = {};
}
OoNavigator.popInitPage(context);
},
)
],
);
},
);
}
Future<void> _onBackPress() {
return await showDialog<Null>(
...
);
}
참조 링크: flutter