tap method

bool? tap(
  1. double offset
)

Taps the slider at given offset, in logical pixels, along the track.

Returns:

  • true if the offset moves the min edge
  • false if the offset moves the max edge
  • null if the offset did not move either edge

The offset is relative to the origin defined by FSlider.layout.

Implementation

bool? tap(double offset) {
  if (allowedInteraction == FSliderInteraction.slide || allowedInteraction == FSliderInteraction.slideThumb) {
    return null;
  }

  if (_selection case final selection?) {
    final min = switch (extendable) {
      (min: true, max: true) when offset < selection.rawOffset.min => true,
      (min: true, max: true) when selection.rawOffset.max < offset => false,
      (min: true, max: false) => true,
      (min: false, max: true) => false,
      _ => null,
    };

    if (min != null) {
      this.selection = selection.move(min: min, to: offset);
    }

    return min;
  }

  return null;
}