class RoutePageWithValue extends StatelessWidget {
final String lastPageName;

BuildContext context;

RoutePageWithValue(this.lastPageName);

_showDialog() {
showDialog(
context: context,
child: new AlertDialog(content: new Text(‘退出当前界面’), actions: [
new FlatButton(
onPressed: () {
Navigator.pop(context);
Navigator.of(context).pop();
},
child: new Text(‘确定’))
]),
);
}

Future _requestPop() {
_showDialog();
return new Future.value(false);
}

@override
Widget build(BuildContext context) {
this.context = context;
//监听左上角返回和实体返回
return new WillPopScope(
child: new Scaffold(
appBar: new AppBar(
title: new Text(‘RoutePageWithValue’),
centerTitle: true,
),
body: new Center(
child: new Text(‘$lastPageName’),
)),
onWillPop: _requestPop);
}
}

发表评论

邮箱地址不会被公开。 必填项已用*标注