mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Scrollbar respect the NeverScrollableScrollPhysics physics (#109609)
This commit is contained in:
parent
143a09d09d
commit
3d94a014b7
@ -1772,6 +1772,10 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
|
||||
@mustCallSuper
|
||||
void handleThumbPressUpdate(Offset localPosition) {
|
||||
assert(_debugCheckHasValidScrollPosition());
|
||||
final ScrollPosition position = _currentController!.position;
|
||||
if (!position.physics.shouldAcceptUserOffset(position)) {
|
||||
return;
|
||||
}
|
||||
final Axis? direction = getScrollbarDirection();
|
||||
if (direction == null) {
|
||||
return;
|
||||
@ -1799,6 +1803,11 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
|
||||
assert(_debugCheckHasValidScrollPosition());
|
||||
_currentController = widget.controller ?? PrimaryScrollController.of(context);
|
||||
|
||||
final ScrollPosition position = _currentController!.position;
|
||||
if (!position.physics.shouldAcceptUserOffset(position)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double scrollIncrement;
|
||||
// Is an increment calculator available?
|
||||
final ScrollIncrementCalculator? calculator = Scrollable.of(
|
||||
|
@ -2675,4 +2675,46 @@ void main() {
|
||||
..rect(rect: const Rect.fromLTRB(694.0, 100.0, 700.0, 121.0)) // thumb
|
||||
); // thumb
|
||||
});
|
||||
|
||||
testWidgets('Scrollbar respect the NeverScrollableScrollPhysics physics', (WidgetTester tester) async {
|
||||
final ScrollController scrollController = ScrollController();
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: PrimaryScrollController(
|
||||
controller: scrollController,
|
||||
child: RawScrollbar(
|
||||
thumbVisibility: true,
|
||||
controller: scrollController,
|
||||
child: const SingleChildScrollView(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
child: SizedBox(width: 4000.0, height: 4000.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(scrollController.offset, 0.0);
|
||||
|
||||
// Drag the thumb down to scroll down.
|
||||
const double scrollAmount = 10.0;
|
||||
final TestGesture dragScrollbarGesture = await tester.startGesture(const Offset(797.0, 45.0));
|
||||
await tester.pumpAndSettle();
|
||||
await dragScrollbarGesture.moveBy(const Offset(0.0, scrollAmount));
|
||||
await tester.pumpAndSettle();
|
||||
await dragScrollbarGesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(scrollController.offset, 0.0);
|
||||
|
||||
// Tap on the track area below the thumb.
|
||||
await tester.tapAt(const Offset(797.0, 550.0));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(scrollController.offset, 0.0);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user