DrivenScrollActivity constructor Null safety

DrivenScrollActivity(
  1. ScrollActivityDelegate delegate,
  2. {required double from,
  3. required double to,
  4. required Duration duration,
  5. required Curve curve,
  6. required TickerProvider vsync}
)

Creates an activity that animates a scroll view based on animation parameters.

All of the parameters must be non-null.

Implementation

DrivenScrollActivity(
  super.delegate, {
  required double from,
  required double to,
  required Duration duration,
  required Curve curve,
  required TickerProvider vsync,
}) : assert(from != null),
     assert(to != null),
     assert(duration != null),
     assert(duration > Duration.zero),
     assert(curve != null) {
  _completer = Completer<void>();
  _controller = AnimationController.unbounded(
    value: from,
    debugLabel: objectRuntimeType(this, 'DrivenScrollActivity'),
    vsync: vsync,
  )
    ..addListener(_tick)
    ..animateTo(to, duration: duration, curve: curve)
     .whenComplete(_end); // won't trigger if we dispose _controller first
}