hide method

void hide()

Hides the crosshair if it is displayed.

Implementation

void hide() {
  // ignore: unnecessary_null_comparison
  if (_stateProperties != null) {
    final CrosshairBehaviorRenderer crosshairBehaviorRenderer =
        _stateProperties.crosshairBehaviorRenderer;
    final CrosshairRenderingDetails renderingDetails =
        CrosshairHelper.getRenderingDetails(crosshairBehaviorRenderer);
    if (renderingDetails.crosshairPainter != null) {
      renderingDetails.crosshairPainter!.canResetPath = false;
      ValueNotifier<int>(renderingDetails.crosshairPainter!.stateProperties
          .repaintNotifiers['crosshair']!.value++);
      renderingDetails.crosshairPainter!.timer?.cancel();
      if (!_stateProperties.isTouchUp) {
        renderingDetails.crosshairPainter!.stateProperties
            .repaintNotifiers['crosshair']!.value++;
        renderingDetails.crosshairPainter!.canResetPath = true;
        renderingDetails.position = null;
      } else {
        if (!shouldAlwaysShow) {
          final double duration = (hideDelay == 0 &&
                  renderingDetails.crosshairPainter!.stateProperties
                          .enableDoubleTap ==
                      true)
              ? 200
              : hideDelay;
          renderingDetails.crosshairPainter!.timer =
              Timer(Duration(milliseconds: duration.toInt()), () {
            renderingDetails.crosshairPainter!.stateProperties
                .repaintNotifiers['crosshair']!.value++;
            renderingDetails.crosshairPainter!.canResetPath = true;
            renderingDetails.position = null;
          });
        }
      }
    }
  }
}