Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

你们的PopScope正常嘛,我这边canPop=false时在iOS上依然能够侧滑返回,android上倒是正常 #3060

Open
weigoudan opened this issue Mar 21, 2024 · 8 comments
Assignees

Comments

@weigoudan
Copy link

rt,难道只有我一个人遇到这个情况?以前用WillPopScope已经弄好的逻辑和功能,最近在更新flutter版本之后,顺便把WillPopScope换到PopScope,然后就gg了,iOS上canPop=false时也能侧滑返回。

然后,新建了个demo工程,没有使用getx却是正常的,canPop=false时不能侧滑返回,惊不惊喜。

本来还以为惹不起,躲得起,想用回WillPopScope,居然无论onWillPop设置true还是false,ios都不能侧滑返回,666...

get版本4.6.6,flutter版本3.16.3
flutter doctor:
[✓] Flutter (Channel stable, 3.16.3, on macOS 14.2.1 23C71 darwin-arm64
(Rosetta), locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.87.2)

@xiajie0
Copy link

xiajie0 commented Mar 21, 2024

GetPage里面设置popGesture: false可以解决

@weigoudan
Copy link
Author

GetPage里面设置popGesture: false可以解决

这个一刀切有点不符合我这边的逻辑,我这边的场景就类似打开一个只有一个webview的页面,webview加载了很多层的url,侧滑返回时要让webview.goback(),webview不能回退时再侧滑就退出当前页面。
就差不多是这样的,根据不同情况来判断处理侧滑事件

@xiajie0
Copy link

xiajie0 commented Mar 22, 2024

试试这两:
adaptive_will_pop_scope
adaptive_pop_scope

我感觉在iOS上拦截侧滑是个很奇怪的事情,侧滑本身已经触发了动画,这时候拦截掉,体验不是很友好

@yanashenyang
Copy link

same same

@weigoudan
Copy link
Author

试试这两: adaptive_will_pop_scope adaptive_pop_scope

我感觉在iOS上拦截侧滑是个很奇怪的事情,侧滑本身已经触发了动画,这时候拦截掉,体验不是很友好

不好意思,这几天太忙没看,这个拦截侧滑就是要在侧滑开始之前拦截啊,不是已经发生侧滑了才拦截。WillPopScope就是处理这种的,监听到这个动作的时候可以让你决定在onWillPop返回是否可以侧滑

@lalayiersan
Copy link

Same to me

@qiuyan81
Copy link

qiuyan81 commented Apr 4, 2024

return PopScope(
  canPop: false,
  child: Scaffold(
            appBar: AppBar(
              leading: BackButton(onPressed:() => Get.back(),),   问题解决了 canPop: false,然后自定义BackButton事件;

@zhushenwudi
Copy link

zhushenwudi commented Apr 14, 2024

我这边也是一样的情况,我想根据一个变量去判断是否可以侧滑退出

WillPopScope(
      onWillPop: widget.logic.state.isSelect ? () async => false : null,
      child: Container()
);

之前在WillPopScope上可以正常运作的。但是升级到PopScope就无法实现我这边想要的功能

修改后如下

PopScope(
      canPop: widget.logic.state.isSelect, // 这里测试无论是true还是false,IOS都可以侧滑返回
      onPopInvoked: (didPop){
          print(didPop);
      },
      child: Container()
);

@weigoudan 不过我这边回退到WillPopScope还是能够保留原始功能的,不像你说的设置true还是false都会侧滑退出,惹不起惹不起

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants