build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Override this method to build widgets that depend on the state of the listenable (e.g., the current value of the animation).

Implementation

@override
Widget build(BuildContext context) {
  Alignment _alignment;
  double _angle;
  if (direction == TextDirection.rtl) {
    // 从右至左
    _alignment = turns.status == AnimationStatus.forward
        ? Alignment.bottomRight
        : Alignment.bottomLeft;
    _angle = turns.value * (math.pi) * 0.5 - math.pi * 0.5;
    if (turns.status == AnimationStatus.forward) {
      _angle = -(turns.value) * (math.pi) * .5 + math.pi * 0.5;
    }
  } else {
    // 从左到右
    _alignment = turns.status == AnimationStatus.forward
        ? Alignment.bottomLeft
        : Alignment.bottomRight;
    _angle = -(turns.value * (math.pi) * 0.5) - math.pi * 1.5;
    if (turns.status == AnimationStatus.forward) {
      _angle = turns.value * math.pi * 0.5 + math.pi * 1.5;
    }
  }
  return Transform(
    transform: Matrix4.rotationZ(_angle)..rotateY(_angle),
    alignment: _alignment,
    filterQuality: filterQuality,
    child: child,
  );
}