addPosition method

  1. @override
void addPosition(
  1. Duration time,
  2. Offset position
)
override

Adds a position as the given time to the tracker.

Implementation

@override
void addPosition(Duration time, Offset position) {
  _sinceLastSample.start();
  _sinceLastSample.reset();
  assert(() {
    final _PointAtTime? previousPoint = _touchSamples[_index];
    if (previousPoint == null || previousPoint.time <= time) {
      return true;
    }
    throw FlutterError(
      'The position being added ($position) has a smaller timestamp ($time) '
      'than its predecessor: $previousPoint.',
    );
  }());
  _index = (_index + 1) % _sampleSize;
  _touchSamples[_index] = _PointAtTime(position, time);
}