Flutter:pageView似乎忽略了pagecontroller s setState之后的页面属性

发布于 2025-02-11 11:17:07 字数 827 浏览 1 评论 0 原文

我遇到了以下问题:我的库 easy_image_viewer 有一个请求添加滑动到dismiss的请求。我使用 diver -Code 小部件实现了它。但是,当用户放大图像时,我注意到我必须找到一种“停用”可被关闭的小部件的方法,因为否则用户无法在缩放映像上徘徊。我通过使用 setState divionDirection 变量来解决该问题,可以是 none down 。 现在,对于怪异的部分:每当我调用 setState divionDirection 更改时,页面浏览量就会跳回第一个项目。我已经尝试使用自动keepapaliveclientmixin ,但无济于事。

代码可以在此处找到:

只需运行应用程序( example/lib/main.dart ),点击显示多个图像(Simple),滑动到第二张图像并使用Pinch&amp ;缩放以缩放。您会注意到它跳回第一个图像。我在做什么错?

I'm having the following problem: My library easy_image_viewer has a request to add swipe-to-dismiss. I implemented it using the Dismissible widget. However, when the user zooms in on an image, I noticed I had to find a way to "deactivate" the Dismissible widget because otherwise the user can't pan around on the zoomed-in image. I solved that by using setState and a dismissDirection variable on the state that can be either none or down.
Now for the weird part: Whenever I call setState and the dismissDirection changes, the PageView jumps back to the first item. I've tried using AutomaticKeepAliveClientMixin, but to no avail.

The code can be found here: https://github.com/thesmythgroup/easy_image_viewer/tree/pagecontroller_problem_demo

Simply run the app (example/lib/main.dart), tap on Show Multiple Images (Simple), swipe to the second image and use pinch & zoom to zoom in. You'll notice it jumps back to the first image. What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对你而言 2025-02-18 11:17:07

您可以使用 confircondismiss 我打开了一个PR,我打开了一个PR,我打开了一个PR,供您检查在这里

Instead of changing the dismiss direction you can use confirmDismiss i opened a PR for you to check here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文