问题
I put a slider on a CustomScollView, When I drag the slider, the scrollview will scroll up and down slightly, so my question is When I drag the slider, how to fibidden scroll of the scrollview?
This slider is custom slider which extends RenderConstrainedBox
class _RenderCupertinoSlider extends RenderConstrainedBox {
_RenderCupertinoSlider(){
_drag = new HorizontalDragGestureRecognizer()
..onStart = _handleDragStart
..onUpdate = _handleDragUpdate
..onEnd = _handleDragEnd;
}
HorizontalDragGestureRecognizer _drag;
@override
bool hitTestSelf(Offset position) {
print("hitTestSelf");
if ((position.dx - _minThumbCenter).abs() < Circle_Radius + _kPadding) {
pickedThumb = _kMinThumb; // _kMinThumb = 1
print("hitTestSelf true");
return true;
}
if ((position.dx - _maxThumbCenter).abs() < Circle_Radius + _kPadding) {
pickedThumb = _kMaxThumb; // _kMaxThumb = 2
return true;
}
return false;
}
@override
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
assert(debugHandleEvent(event, entry));
if (event is PointerDownEvent) _drag.addPointer(event);
}
}
来源:https://stackoverflow.com/questions/62759601/flutter-how-to-prevent-scrollview-scroll-when-i-drag-a-slider-on-it