title: How to run an animation in loop
body: <p>I'm shaking a widget using the below code, but the effect is once,</p>
  <p>how do I keep it running in a loop at timed intervals. I believe it can be done by changing the key but it's a final and can't be changed.</p>
  <pre><code>import 'package:flutter/material.dart';
  
  @immutable
  class ShakeWidget extends StatelessWidget {
    final Duration duration;
    final double deltaX;
    final Widget child;
    final Curve curve;
  
    const ShakeWidget({
      Key key,
      this.duration = const Duration(milliseconds: 500),
      this.deltaX = 20,
      this.curve = Curves.bounceOut,
      this.child,
    }) : super(key: key);
  
    /// convert 0-1 to 0-1-0
    double shake(double animation) =&gt;
        2 * (0.5 - (0.5 - curve.transform(animation)).abs());
  
    @override
    Widget build(BuildContext context) {
      return TweenAnimationBuilder&lt;double&gt;(
        key: key,
        tween: Tween(begin: 0.0, end: 1.0),
        duration: duration,
        builder: (context, animation, child) =&gt; Transform.translate(
          offset: Offset(deltaX * shake(animation), 0),
          child: child,
        ),
        child: child,
      );
    }
  }
  </code></pre>