EzAnimation constructor

EzAnimation(
  1. dynamic begin,
  2. dynamic end,
  3. Duration duration, {
  4. Curve curve = Curves.linear,
  5. Curve reverseCurve = Curves.linear,
  6. BuildContext? context,
  7. OnNavigate onNavigate = OnNavigate.resetAnimation,
  8. TickerProvider? vsync,
})

Implementation

EzAnimation(
  this.begin,
  this.end,
  this.duration, {
  this.curve = Curves.linear,
  this.reverseCurve = Curves.linear,
  this.context,
  this.onNavigate = OnNavigate.resetAnimation,
  this.vsync,
}) {
  _tickerProvider = _CustomProvider();
  _tween = Tween(begin: begin, end: end);
  _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);
  }
}