shakeX static method

AnimatedBuilder shakeX(
  1. Animation<double> animation,
  2. Widget child
)

X轴抖动动画

Implementation

static AnimatedBuilder shakeX(Animation<double> animation, Widget child) {
  return AnimatedBuilder(
    animation: animation,
    builder: (context, child) {
      final dx = sin(animation.value * pi * 10) * 10;
      return Transform.translate(offset: Offset(dx, 0), child: child);
    },
    child: child,
  );
}