【发布时间】:2021-10-20 02:37:54
【问题描述】:
我在我的颤振应用程序中使用 WillPopScope,它禁用了在 IOS 中非常有用的“向左滑动返回”。如何保留 WillPopScope 但重新添加 iOS 手势?
WillPopScope 无法在 ios 上向左滑动返回。
【问题讨论】:
标签: flutter flutter-layout flutter-dependencies flutter-test
我在我的颤振应用程序中使用 WillPopScope,它禁用了在 IOS 中非常有用的“向左滑动返回”。如何保留 WillPopScope 但重新添加 iOS 手势?
WillPopScope 无法在 ios 上向左滑动返回。
【问题讨论】:
标签: flutter flutter-layout flutter-dependencies flutter-test
根据设备类型渲染 WillPopScope
return Platform.isAndroid ? new WillPopScope(
onWillPop: () async {
Navigator.pop(context);
},
child:.......
【讨论】:
根据文档, WillPopScope 注册回调以否决用户尝试关闭封闭。 每当按下(返回按钮 - Android)和(向左滑动 - IOS)时,您都会在 [onWillPop] 处收到回调,
所以, 如果您需要对此进行任何操作 向左滑动。 您只需在此处添加您的代码操作(示例 - 后退导航)。 像这样,
return new WillPopScope(
onWillPop: () async {
Navigator.pop(context);
},
child:.....
【讨论】: