hide method

void hide()

Hides the trackball if it is displayed.

Implementation

void hide() {
  final CartesianStateProperties stateProperties = _stateProperties;
  final TrackballRenderingDetails trackballRenderingDetails =
      TrackballHelper.getRenderingDetails(
          _stateProperties.trackballBehaviorRenderer);
  if (trackballRenderingDetails.trackballPainter != null &&
      !trackballRenderingDetails.isTrackballTemplate) {
    if (stateProperties.chart.trackballBehavior.activationMode ==
        ActivationMode.doubleTap) {
      trackballRenderingDetails.trackballPainter!.canResetPath = false;
      ValueNotifier<int>(trackballRenderingDetails.trackballPainter!
          .stateProperties.repaintNotifiers['trackball']!.value++);
      if (trackballRenderingDetails.trackballPainter!.timer != null) {
        trackballRenderingDetails.trackballPainter!.timer?.cancel();
      }
    }
    if (!stateProperties.isTouchUp) {
      trackballRenderingDetails.trackballPainter!.stateProperties
          .repaintNotifiers['trackball']!.value++;
      trackballRenderingDetails.chartPointInfo.clear();
      trackballRenderingDetails.trackballPainter!.canResetPath = true;
    } else {
      final double duration =
          (hideDelay == 0 && stateProperties.enableDoubleTap)
              ? 200
              : hideDelay;
      if (!shouldAlwaysShow) {
        if (trackballRenderingDetails.trackballPainter!.timer != null) {
          trackballRenderingDetails.trackballPainter!.timer!.cancel();
        }
        trackballRenderingDetails.trackballPainter!.timer =
            Timer(Duration(milliseconds: duration.toInt()), () {
          trackballRenderingDetails.trackballPainter!.stateProperties
              .repaintNotifiers['trackball']!.value++;
          trackballRenderingDetails.trackballPainter!.canResetPath = true;
          trackballRenderingDetails.chartPointInfo.clear();
        });
      }
    }
  } else if (trackballRenderingDetails.trackballTemplate != null) {
    GlobalKey key =
        trackballRenderingDetails.trackballTemplate!.key as GlobalKey;
    TrackballTemplateState? trackballTemplateState =
        key.currentState as TrackballTemplateState;
    final double duration = shouldAlwaysShow ||
            (hideDelay == 0 && stateProperties.enableDoubleTap)
        ? 200
        : hideDelay;
    if (!stateProperties.isTrackballOrientationChanged) {
      stateProperties.trackballTimer =
          Timer(Duration(milliseconds: duration.toInt()), () {
        if (stateProperties.isTrackballOrientationChanged) {
          key = trackballRenderingDetails.trackballTemplate!.key as GlobalKey;
          trackballTemplateState = key.currentState as TrackballTemplateState;
        }
        trackballTemplateState!.hideTrackballTemplate();
        stateProperties.isTrackballOrientationChanged = false;
        trackballRenderingDetails.chartPointInfo.clear();
      });
    }
  }
}