shake method
Shake animation
Implementation
Widget shake({
Duration duration = const Duration(milliseconds: 500),
}) {
return TweenAnimationBuilder<double>(
tween: Tween(begin: 0.0, end: 1.0),
duration: duration,
builder: (context, value, child) {
return Transform.translate(
offset: Offset(
(1.0 - value) * 10 * (value % 0.5 == 0 ? 1 : -1),
0.0,
),
child: child,
);
},
child: this,
);
}