RouteSimulator constructor

RouteSimulator(
  1. List<LatLng> listLatLng,
  2. TickerProvider vsync, {
  3. double speed = 0.001,
  4. bool repeat = false,
  5. Duration duration = const Duration(seconds: 10),
  6. dynamic onLocationChange(
    1. LatLng
    )?,
  7. double upperBound = 2.2,
  8. AnimationBehavior animationBehavior = AnimationBehavior.normal,
})

vsync from TickerProviderStateMixin class, used to init AnimationController

Implementation

RouteSimulator(List<LatLng> listLatLng, TickerProvider vsync,
    {double speed = 0.001,
    bool repeat = false,
    this.duration = const Duration(seconds: 10),
    Function(LatLng)? onLocationChange,
    double upperBound = 2.2,
    AnimationBehavior animationBehavior = AnimationBehavior.normal}) {
  _polyline = PolylineAnimation(listLatLng);
  _currentDistance = 0;
  _speed = speed;
  _onLocationChange = onLocationChange;
  _animationController = AnimationController(
      upperBound: upperBound,
      vsync: vsync,
      duration: duration,
      animationBehavior: animationBehavior)
    ..forward()
    ..addListener(() {
      if (_animationController.isCompleted && repeat) {
        _animationController.repeat();
      }
    });
}