Flutter:带有 CupertinoNavigationBar 后退按钮的警报对话框
Flutter: Alert Dialog with CupertinoNavigationBar back button
颤动问题:
我正在尝试在我的 Cupertino 导航栏后退按钮上实现一个警告对话框,但我想我不知道当我不使用自定义后退按钮时它会如何工作。
有人知道吗?
class ameriCares extends StatelessWidget {
const ameriCares({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(middle: Text("Americares")), //i want to add the alert dialog here on the back button
child: SafeArea(
child: WebView(
initialUrl: AppLocalizations.of(context)!.americares,
javascriptMode: JavascriptMode.unrestricted,
),
//bottomNavigationBar: CustomBottomNavBar(selectedMenu: MenuState.give),
),
);
}
}
万分感谢
尝试向 CupertinoNavigationBar - GestureDetector 添加一个带图标的前导参数。
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text(
"Americares",
),
leading: GestureDetector(
onTap: () {
showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: const Text('AlertDialog Title'),
content: SingleChildScrollView(
child: ListBody(
children: const <Widget>[
Text('This is a demo alert dialog.'),
Text('Would you like to approve of this message?'),
],
),
),
actions: <Widget>[
TextButton(
child: const Text('Approve'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
},
child: Icon(
CupertinoIcons.left_chevron,
color: CupertinoColors.black,
),
),
), //i want to add the alert dialog here on the back button
child: SafeArea(
child: WebView(
initialUrl: AppLocalizations.of(context)!.americares,
javascriptMode: JavascriptMode.unrestricted,
),
//bottomNavigationBar: CustomBottomNavBar(selectedMenu: MenuState.give),
),
);
}
颤动问题: 我正在尝试在我的 Cupertino 导航栏后退按钮上实现一个警告对话框,但我想我不知道当我不使用自定义后退按钮时它会如何工作。
有人知道吗?
class ameriCares extends StatelessWidget {
const ameriCares({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(middle: Text("Americares")), //i want to add the alert dialog here on the back button
child: SafeArea(
child: WebView(
initialUrl: AppLocalizations.of(context)!.americares,
javascriptMode: JavascriptMode.unrestricted,
),
//bottomNavigationBar: CustomBottomNavBar(selectedMenu: MenuState.give),
),
);
}
}
万分感谢
尝试向 CupertinoNavigationBar - GestureDetector 添加一个带图标的前导参数。
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text(
"Americares",
),
leading: GestureDetector(
onTap: () {
showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: const Text('AlertDialog Title'),
content: SingleChildScrollView(
child: ListBody(
children: const <Widget>[
Text('This is a demo alert dialog.'),
Text('Would you like to approve of this message?'),
],
),
),
actions: <Widget>[
TextButton(
child: const Text('Approve'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
},
child: Icon(
CupertinoIcons.left_chevron,
color: CupertinoColors.black,
),
),
), //i want to add the alert dialog here on the back button
child: SafeArea(
child: WebView(
initialUrl: AppLocalizations.of(context)!.americares,
javascriptMode: JavascriptMode.unrestricted,
),
//bottomNavigationBar: CustomBottomNavBar(selectedMenu: MenuState.give),
),
);
}