Fluttter Shake Animation
Usage
Create an instance of ShakeController; takes TickerProvider and Duration(Optional
, default=200 millis
) as params.
ShakeController _shakeController;
@override
void initState() {
_shakeController = ShakeController(vsync: this);
super.initState();
}
Wrap your widget inside a ShakeView Widget
@override
Widget build(BuildContext context) {
return ShakeView(
controller: _shakeController,
child: Container(
height: 100,
width: 100,
color: Theme.of(context).accentColor,
child: Center(
child: Text('I can shake',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 30))),
)
);
}
Trigger a shake animation by calling _shakeController.shake()
.