Unverified Commit 68068845 authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Fix scrollbar track offset (#106835)

parent 0eed9add
...@@ -488,7 +488,7 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter { ...@@ -488,7 +488,7 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter {
trackSize = Size(thickness + 2 * crossAxisMargin, _trackExtent); trackSize = Size(thickness + 2 * crossAxisMargin, _trackExtent);
x = crossAxisMargin + padding.left; x = crossAxisMargin + padding.left;
y = _thumbOffset; y = _thumbOffset;
trackOffset = Offset(x - crossAxisMargin, mainAxisMargin); trackOffset = Offset(x - crossAxisMargin, mainAxisMargin + padding.top);
borderStart = trackOffset + Offset(trackSize.width, 0.0); borderStart = trackOffset + Offset(trackSize.width, 0.0);
borderEnd = Offset(trackOffset.dx + trackSize.width, trackOffset.dy + _trackExtent); borderEnd = Offset(trackOffset.dx + trackSize.width, trackOffset.dy + _trackExtent);
break; break;
...@@ -497,7 +497,7 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter { ...@@ -497,7 +497,7 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter {
trackSize = Size(thickness + 2 * crossAxisMargin, _trackExtent); trackSize = Size(thickness + 2 * crossAxisMargin, _trackExtent);
x = size.width - thickness - crossAxisMargin - padding.right; x = size.width - thickness - crossAxisMargin - padding.right;
y = _thumbOffset; y = _thumbOffset;
trackOffset = Offset(x - crossAxisMargin, mainAxisMargin); trackOffset = Offset(x - crossAxisMargin, mainAxisMargin + padding.top);
borderStart = trackOffset; borderStart = trackOffset;
borderEnd = Offset(trackOffset.dx, trackOffset.dy + _trackExtent); borderEnd = Offset(trackOffset.dx, trackOffset.dy + _trackExtent);
break; break;
...@@ -506,7 +506,7 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter { ...@@ -506,7 +506,7 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter {
trackSize = Size(_trackExtent, thickness + 2 * crossAxisMargin); trackSize = Size(_trackExtent, thickness + 2 * crossAxisMargin);
x = _thumbOffset; x = _thumbOffset;
y = crossAxisMargin + padding.top; y = crossAxisMargin + padding.top;
trackOffset = Offset(mainAxisMargin, y - crossAxisMargin); trackOffset = Offset(mainAxisMargin + padding.left, y - crossAxisMargin);
borderStart = trackOffset + Offset(0.0, trackSize.height); borderStart = trackOffset + Offset(0.0, trackSize.height);
borderEnd = Offset(trackOffset.dx + _trackExtent, trackOffset.dy + trackSize.height); borderEnd = Offset(trackOffset.dx + _trackExtent, trackOffset.dy + trackSize.height);
break; break;
...@@ -515,7 +515,7 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter { ...@@ -515,7 +515,7 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter {
trackSize = Size(_trackExtent, thickness + 2 * crossAxisMargin); trackSize = Size(_trackExtent, thickness + 2 * crossAxisMargin);
x = _thumbOffset; x = _thumbOffset;
y = size.height - thickness - crossAxisMargin - padding.bottom; y = size.height - thickness - crossAxisMargin - padding.bottom;
trackOffset = Offset(mainAxisMargin, y - crossAxisMargin); trackOffset = Offset(mainAxisMargin + padding.left, y - crossAxisMargin);
borderStart = trackOffset; borderStart = trackOffset;
borderEnd = Offset(trackOffset.dx + _trackExtent, trackOffset.dy); borderEnd = Offset(trackOffset.dx + _trackExtent, trackOffset.dy);
break; break;
......
...@@ -2565,4 +2565,36 @@ void main() { ...@@ -2565,4 +2565,36 @@ void main() {
// Go without throw. // Go without throw.
}); });
testWidgets('Track offset respects padding', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/106834
final ScrollController scrollController = ScrollController();
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: MediaQuery(
data: const MediaQueryData(
padding: EdgeInsets.all(50.0),
),
child: RawScrollbar(
controller: scrollController,
minThumbLength: 21,
minOverscrollLength: 8,
thumbVisibility: true,
child: SingleChildScrollView(
controller: scrollController,
child: const SizedBox(width: 1000.0, height: 50000.0),
),
),
)
)
);
await tester.pumpAndSettle();
expect(
find.byType(RawScrollbar),
paints
..rect(rect: const Rect.fromLTRB(744.0, 50.0, 750.0, 550.0)) // track
..rect(rect: const Rect.fromLTRB(744.0, 50.0, 750.0, 71.0))
); // thumb
});
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment