hinge static method
垂直悬挂动画
Implementation
static AnimatedBuilder hinge(
Animation<double> animation,
Widget child,
) {
return AnimatedBuilder(
animation: animation,
builder: (context, child) {
final angle = animation.value < 0.5
? (animation.value * 2 * math.pi / 18)
: (math.pi / 18);
final offset = animation.value < 0.5 ? 0.0 : 100.0 * animation.value;
return Transform(
alignment: Alignment.topLeft,
transform: Matrix4.rotationZ(angle)..translate(0.0, offset),
child: Opacity(
opacity:
animation.value < 0.5 ? 1.0 : 1.0 - (animation.value - 0.5) * 2,
child: child,
),
);
},
child: child,
);
}