build method

  1. @override
Widget build(
  1. BuildContext context,
  2. Widget child,
  3. AnimationController controller,
  4. EffectEntry entry,
)
override

Builds the widgets necessary to implement the effect, based on the provided AnimationController and EffectEntry.

Implementation

@override
Widget build(
  BuildContext context,
  Widget child,
  AnimationController controller,
  EffectEntry entry,
) {
  Animation<double> animation = buildAnimation(controller, entry);
  return getOptimizedBuilder<double>(
    animation: animation,
    builder: (_, __) {
      double value = animation.value * pi;

      final Matrix4 mtx = Matrix4(
        1.0, 0.0, 0.0, 0.0, //
        0.0, 1.0, 0.0, 0.0, //
        0.0, 0.0, 1.0, 0.002 * perspective, //
        0.0, 0.0, 0.0, 1.0,
      );
      if (value != 0) {
        if (direction == Axis.vertical) {
          mtx.rotateX(value);
        } else {
          mtx.rotateY(value);
        }
      }

      return Transform(alignment: alignment, transform: mtx, child: child);
    },
  );
}