handleDoubleTap method

  1. @protected
void handleDoubleTap()

Implementation

@protected
void handleDoubleTap() {
  if (doubleTapDetails == null) {
    return;
  }
  final double currentScale =
      transformationController!.value.getScaleOnZAxis();
  final double pos1Scale = doubleTabZoomOutScale;
  const double pos2Scale = 1;
  final position = doubleTapDetails!.localPosition;

  //Zoom to no zoom when a) the user is already zoomed out or b)
  //the user is zoomed in and the table is bigger than standard size

  //Because we cant compare doubles, we have to check if the difference is smaller than 0.01 (no noticeable difference for the user)
  final bool zoomToNormal =
      ((currentScale - pos1Scale).abs() < 0.01) || currentScale > pos2Scale;

  final double scaleChange =
      (zoomToNormal ? pos2Scale : pos1Scale) / currentScale;

  Matrix4 newM = getScaled(scale: scaleChange);
  animateTo(newM, noTranslation: true, focalPoint: position);
}