【问题标题】:WillPopScope disable the swipe left to go back in IOS FlutterWillPopScope 在 IOS Flutter 中禁用向左滑动返回
【发布时间】:2021-10-20 02:37:54
【问题描述】:

我在我的颤振应用程序中使用 WillPopScope,它禁用了在 IOS 中非常有用的“向左滑动返回”。如何保留 WillPopScope 但重新添加 iOS 手势?

WillPopScope 无法在 ios 上向左滑动返回。

【问题讨论】:

    标签: flutter flutter-layout flutter-dependencies flutter-test


    【解决方案1】:

    根据设备类型渲染 WillPopScope

      return     Platform.isAndroid ? new WillPopScope(
                    onWillPop: () async {
                      Navigator.pop(context);
                   },
                  child:.......
       
    

    【讨论】:

      【解决方案2】:

      根据文档, WillPopScope 注册回调以否决用户尝试关闭封闭。 每当按下(返回按钮 - Android)和(向左滑动 - IOS)时,您都会在 [onWillPop] 处收到回调,

      所以, 如果您需要对此进行任何操作 向左滑动。 您只需在此处添加您的代码操作(示例 - 后退导航)。 像这样,

       return new WillPopScope(
              onWillPop: () async {
               Navigator.pop(context);
              },
              child:.....
      

      【讨论】:

        猜你喜欢
        • 2022-10-21
        • 2018-08-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-05-02
        • 2019-04-16
        相关资源
        最近更新 更多