hitTest method
Called whenever a hit test is being performed on an object that is using this custom paint delegate.
The given point is relative to the same coordinate space as the last paint call.
The default behavior is to consider all points to be hits for background painters, and no points to be hits for foreground painters.
Return true if the given position corresponds to a point on the drawn image that should be considered a "hit", false if it corresponds to a point that should be considered outside the painted image, and null to use the default behavior.
Implementation
@override
bool? hitTest(Offset? position) {
// There is nothing painted to hit.
if (_thumbRect == null) {
return null;
}
// Interaction disabled.
if (ignorePointer
// The thumb is not able to be hit when transparent.
||
fadeoutOpacityAnimation.value == 0.0
// Not scrollable
||
!_lastMetricsAreScrollable) {
return false;
}
return _trackRect!.contains(position!);
}