事实证明,
flightShuttleBuilder
仅在过渡的开始和结束处发射值,而不是在整个动画中。捕捉来自
this issue on GitHub
显然是预期行为。
解决方法是创建您自己的过渡,从
AnimatedWidget
;它将正常发出值,并且可以在
飞行航天飞机制造商
:
class FlipcardTransition extends AnimatedWidget {
final Animation<double> flipAnim;
final Widget child;
FlipcardTransition({@required this.flipAnim, @required this.child})
: assert(flipAnim != null),
assert(child != null),
super(listenable: flipAnim);
@override
Widget build(BuildContext context) {
return Transform(
transform: Matrix4.identity()
..rotateY(-pi * flipAnim.value),
alignment: FractionalOffset.center,
child: child,
);
}
}
...
flightShuttleBuilder: (BuildContext flightContext,
Animation<double> animation,
HeroFlightDirection flightDirection,
BuildContext fromHeroContext,
BuildContext toHeroContext,) {
final Hero toHero = toHeroContext.widget;
return FlipcardTransition(
flipAnim: animation,
child: toHero,
);
},