【发布时间】:2019-08-05 10:38:25
【问题描述】:
我用WillPopScope 覆盖了我的Scaffold,但是在滑动返回iOS 时不会调用onWillPop 回调。
这可能是什么原因?
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async {
print("onWillPop"); // is not printed to the console
if (Navigator.of(context).userGestureInProgress)
return false;
else
return true;
},
child: new Scaffold(
appBar: new AppBar(
title: new Text("App Title"),
),
body: Stack(
children: <Widget>[
...widgets...
],
),
),
);
}
【问题讨论】: