diff --git a/packages/flutter/lib/src/material/scrollbar.dart b/packages/flutter/lib/src/material/scrollbar.dart index c274695eed3..561c3917dd4 100644 --- a/packages/flutter/lib/src/material/scrollbar.dart +++ b/packages/flutter/lib/src/material/scrollbar.dart @@ -326,7 +326,8 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> { MaterialStateProperty get _thickness { return MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.hovered) && _trackVisibility.resolve(states)) { - return _scrollbarTheme.thickness?.resolve(states) + return widget.thickness + ?? _scrollbarTheme.thickness?.resolve(states) ?? _kScrollbarThicknessWithTrack; } // The default scrollbar thickness is smaller on mobile. diff --git a/packages/flutter/test/material/scrollbar_theme_test.dart b/packages/flutter/test/material/scrollbar_theme_test.dart index 635fa6fb2f5..642cab7aa68 100644 --- a/packages/flutter/test/material/scrollbar_theme_test.dart +++ b/packages/flutter/test/material/scrollbar_theme_test.dart @@ -362,6 +362,7 @@ void main() { testWidgets('Scrollbar widget properties take priority over theme', (WidgetTester tester) async { const double thickness = 4.0; + const double edgeMargin = 2.0; const bool showTrackOnHover = true; const Radius radius = Radius.circular(3.0); final ScrollController scrollController = ScrollController(); @@ -394,14 +395,14 @@ void main() { find.byType(Scrollbar), paints..rrect( rrect: RRect.fromRectAndRadius( - const Rect.fromLTRB(794.0, 0.0, 798.0, 90.0), + const Rect.fromLTRB(800 - thickness - edgeMargin, 0.0, 798.0, 90.0), const Radius.circular(3.0), ), color: _kDefaultIdleThumbColor, ), ); - // Drag scrollbar behavior + // Drag scrollbar behavior. const double scrollAmount = 10.0; final TestGesture dragScrollbarGesture = await tester.startGesture(const Offset(797.0, 45.0)); await tester.pumpAndSettle(); @@ -410,7 +411,7 @@ void main() { find.byType(Scrollbar), paints..rrect( rrect: RRect.fromRectAndRadius( - const Rect.fromLTRB(794.0, 0.0, 798.0, 90.0), + const Rect.fromLTRB(800 - thickness - edgeMargin, 0.0, 798.0, 90.0), const Radius.circular(3.0), ), // Drag color @@ -423,7 +424,7 @@ void main() { await dragScrollbarGesture.up(); await tester.pumpAndSettle(); - // Hover scrollbar behavior + // Hover scrollbar behavior. final TestGesture gesture = await tester.createGesture(kind: ui.PointerDeviceKind.mouse); await gesture.addPointer(); await gesture.moveTo(const Offset(794.0, 5.0)); @@ -433,18 +434,18 @@ void main() { find.byType(Scrollbar), paints ..rect( - rect: const Rect.fromLTRB(784.0, 0.0, 800.0, 600.0), + rect: const Rect.fromLTRB(792.0, 0.0, 800.0, 600.0), color: const Color(0x08000000), ) ..line( - p1: const Offset(784.0, 0.0), - p2: const Offset(784.0, 600.0), + p1: const Offset(792.0, 0.0), + p2: const Offset(792.0, 600.0), strokeWidth: 1.0, color: const Color(0x1a000000), ) ..rrect( rrect: RRect.fromRectAndRadius( - const Rect.fromLTRB(786.0, 10.0, 798.0, 100.0), + const Rect.fromLTRB(800 - thickness - edgeMargin, 10.0, 798.0, 100.0), const Radius.circular(3.0), ), // Hover color