有没有办法在特定页面上停用Android后退按钮?
class WakeUpApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: "Time To Wake Up ?",
home: new WakeUpHome(),
routes: <String, WidgetBuilder>{
'/pageOne': (BuildContext context) => new pageOne(),
'/pageTwo': (BuildContext context) => new pageTwo(),
},
);
}
}
Run Code Online (Sandbox Code Playgroud)
在pageOne上我有一个按钮可以转到pageTwo:
new FloatingActionButton(
onPressed: () {
Navigator.of(context).pushNamed('/pageTwo');
},
)
Run Code Online (Sandbox Code Playgroud)
我的问题是,如果我按下Android屏幕底部的后退箭头,我会回到pageOne.我希望这个按钮根本不显示.理想情况下,除非用户将手指按在屏幕上5秒钟,否则我希望没有可能的方法离开此屏幕.(我正在尝试为幼儿写一个应用程序,并希望只有父母能够导航出特定的屏幕).
我建立了一个AlertDialog来显示加载,而我正在验证用户,当它完成后我弹出它.
Widget loadingDialog = new AlertDialog(
content: new Row(
children: <Widget>[
new CircularProgressIndicator(),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text("Loading..."),
),
],
),);
Run Code Online (Sandbox Code Playgroud)
但是,如果用户点击对话框外,它会关闭.因此,当auth完成时,它仍会弹出一些东西(我猜是脚手架),打破了应用程序.如何让Dialog不能关闭?
是否可以防止ModalBottomSheet隐藏免受外界接触?就像showDialog()我们可以使用属性来防止对话框在外部触摸时关闭barrierDismissible