PageView 中类似 Flutter Hero 的过渡 [英] Flutter Hero-like transition in PageView

查看:19
本文介绍了PageView 中类似 Flutter Hero 的过渡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 PageView 的一页中有一张图片.当我转到它时,我想将此图像动画到下一页,有点像在导航器页面转换中使用英雄动画时.有什么想法可以实现吗?

I have an image in one page of the PageView. I want to animate this image to the next page when i go to it, sort of like when you use Hero animations in navigator page transitions. Any ideas how this can be achieved?

推荐答案

这个包做你想做的https://pub.dev/packages/coast

它本质上采用了与 Flutter 的 Hero 和 HeroController 相同的方法:检测何时开始转换,在源页面和目标页面的元素树中搜索标记为动画的小部件(英雄、螃蟹),并根据它们进行配对在它们的标签上,最后在一个 Overlay 中创建一个条目,其位置和大小是源页面和目标页面上的插值.

It is essentially taking the same approach as Flutter’s Hero and HeroController: Detect when a transition is started, search through the element trees of the source and target pages for the widgets marked for animation (heroes, crabs), pair them up based on their tags, and finally create an entry in an Overlay whose position and size is the interpolation between those on the source and target pages.

这篇关于PageView 中类似 Flutter Hero 的过渡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆