Flutter: Disable Swipe to Navigate Back in iOS

后端 未结 7 1109
一向
一向 2020-12-16 15:25

I\'m new to flutter development, and find it a bit frustrating in iOS when you have a navigation drawer and when you swipe to open it, it\'ll perform a Navigation.of(c

7条回答
  •  既然无缘
    2020-12-16 15:57

    You can try this in your Widget build:

    @override
      Widget build(BuildContext context) {
        return WillPopScope(//forbidden swipe in iOS(my ThemeData(platform: TargetPlatform.iOS,)
          onWillPop: ()async {
            if (Navigator.of(context).userGestureInProgress)
              return false;
            else
              return true;
          },
          child: ,
        );
      }
    

提交回复
热议问题