我Scaffold用 覆盖了我的WillPopScope,但是onWillPop在 iOS 上滑动返回时不会调用回调。
这可能是什么原因?
@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...
],
),
),
);
}
Run Code Online (Sandbox Code Playgroud)