endCurrentPath method

void endCurrentPath()

Implementation

void endCurrentPath() {
  if (_isDraging) {
    _isDraging = false;
    if (!_isFinished) {
      Path path = _paths.last;
      Offset lastPoint = path
          .computeMetrics(forceClosed: true)
          .last
          .getTangentForOffset(path.computeMetrics().last.length)!
          .position;
      Offset firstPoint = path
          .computeMetrics()
          .first
          .getTangentForOffset(0)!
          .position;
      if (!prevLocation.rect.contains(firstPoint)) {
        gestureController.addWrongGesture(
          'Draw path',
          'Drew a path which didnt start in ${prevLocation.id}',
        );
        deleteWrong();
      } else if (!nextLocation.rect.contains(lastPoint)) {
        gestureController.addWrongGesture(
          'Draw path',
          'Drew a path which didnt end in ${nextLocation.id}',
        );
        deleteWrong();
      }
    }
  }
}