headShake static method

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

头部摇摆动画

Implementation

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