是否可以使用 Flutter 复制 iOS App Store 的过渡效果?
我尝试通过在两个小部件的根布局中放置两个标签来使用 Hero Animation,但动画看起来很笨拙或不是我所期望的。但好处是我可以在使用 MaterialPageRoute 时向后滑动 iOS。
来源
Hero(
tag: 'heroTag_destinationScreen',
transitionOnUserGestures: true,
flightShuttleBuilder: (BuildContext flightContext,
Animation<double> animation,
HeroFlightDirection flightDirection,
BuildContext fromHeroContext,
BuildContext toHeroContext,) {
final Hero toHero = toHeroContext.widget;
return ScaleTransition(
scale: animation,
child: toHero,
);
},
child: GestureDetector(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) {
return DestinationScreen()
},
),
);
},
child: Card(
...someCardContent
),
),
)
Run Code Online (Sandbox Code Playgroud)
目的地画面
@override
Widget build(BuildContext context) {
return Hero(
tag: 'heroTag_destinationScreen',
child: Scaffold(
appBar: …
Run Code Online (Sandbox Code Playgroud) 是否可以使用英雄动画和向下滑动手势监听器/检测器来实现这种效果?或者有没有我可以使用的已经可用的软件包?
基本上,当我在无状态小部件中向下滑动图像时,它将返回到上一个屏幕并将图像返回到其初始位置,就像下面来自 Reddit 应用程序的示例一样。
我正在为我的图像使用 photo_view 包,以允许用户捏合放大。不确定是否可能存在任何手势冲突。
包: https: //pub.dev/packages/photo_view
抱歉,gif 图像过大,我不知道如何缩小它