小编ahm*_* ay的帖子

Flutter iOS Back Swipe 不调用 onWillPop

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)

dart flutter

7
推荐指数
1
解决办法
5317
查看次数

标签 统计

dart ×1

flutter ×1