EzAnimation.tween constructor

EzAnimation.tween(
  1. Tween<Object?> tween,
  2. Duration duration, {
  3. Curve curve = Curves.linear,
  4. Curve reverseCurve = Curves.linear,
  5. BuildContext? context,
  6. OnNavigate onNavigate = OnNavigate.resetAnimation,
  7. TickerProvider? vsync,
})

Uses the given Tween to create a sequence This is helpful to use things like ColorTween

Implementation

EzAnimation.tween(
  Tween tween,
  this.duration, {
  this.curve = Curves.linear,
  this.reverseCurve = Curves.linear,
  this.context,
  this.onNavigate = OnNavigate.resetAnimation,
  this.vsync,
}) {
  _tickerProvider = _CustomProvider();
  _tween = tween;
  _controller = AnimationController(
      vsync: vsync == null ? _tickerProvider : vsync!, duration: duration);
  _resultAnimation = _tween.animate(CurvedAnimation(
      parent: _controller, curve: curve, reverseCurve: reverseCurve));

  /// If a context is given, we listen to navigation changes
  /// If vsync is provided, this is automatically done by the ticker on the page
  if (context != null && vsync == null) {
    /// Listen for page changes, mute ticker when current context is no longer visible
    _resultAnimation.addListener(_animationObserver);

    /// Adds internal listener
    _listeners.add(_animationObserver);
  }
}