animateTo method

Future<void> animateTo(
  1. TimeRange newValue, {
  2. Curve curve = Curves.easeInOut,
  3. Duration duration = const Duration(milliseconds: 200),
  4. required TickerProvider vsync,
})

Implementation

Future<void> animateTo(
  TimeRange newValue, {
  Curve curve = Curves.easeInOut,
  Duration duration = const Duration(milliseconds: 200),
  required TickerProvider vsync,
}) async {
  assert(_isValidRange(newValue));

  cancelAnimation();
  final previousRange = value;
  _animationController =
      AnimationController(debugLabel: 'TimeController', vsync: vsync)
        ..addListener(() {
          value = TimeRange.lerp(
            previousRange,
            newValue,
            _animationController!.value,
          );
        })
        ..animateTo(1, duration: duration, curve: curve);
}