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

Expose padding on RawScrollbar (#107756)

parent b5590a06
......@@ -944,6 +944,7 @@ class RawScrollbar extends StatefulWidget {
this.scrollbarOrientation,
this.mainAxisMargin = 0.0,
this.crossAxisMargin = 0.0,
this.padding,
@Deprecated(
'Use thumbVisibility instead. '
'This feature was deprecated after v2.9.0-1.0.pre.',
......@@ -1366,6 +1367,13 @@ class RawScrollbar extends StatefulWidget {
/// Must not be null and defaults to 0.
final double crossAxisMargin;
/// The insets by which the scrollbar thumb and track should be padded.
///
/// When null, the inherited [MediaQueryData.padding] is used.
///
/// Defaults to null.
final EdgeInsets? padding;
@override
RawScrollbarState<RawScrollbar> createState() => RawScrollbarState<RawScrollbar>();
}
......@@ -1593,7 +1601,7 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
..textDirection = Directionality.of(context)
..thickness = widget.thickness ?? _kScrollbarThickness
..radius = widget.radius
..padding = MediaQuery.of(context).padding
..padding = widget.padding ?? MediaQuery.of(context).padding
..scrollbarOrientation = widget.scrollbarOrientation
..mainAxisMargin = widget.mainAxisMargin
..shape = widget.shape
......
......@@ -2612,7 +2612,7 @@ void main() {
// Go without throw.
});
testWidgets('Track offset respects padding', (WidgetTester tester) async {
testWidgets('Track offset respects MediaQuery padding', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/106834
final ScrollController scrollController = ScrollController();
await tester.pumpWidget(
......@@ -2640,7 +2640,39 @@ void main() {
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))
..rect(rect: const Rect.fromLTRB(744.0, 50.0, 750.0, 71.0)) // thumb
); // thumb
});
testWidgets('RawScrollbar.padding replaces MediaQueryData.padding', (WidgetTester tester) async {
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,
padding: const EdgeInsets.all(100),
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(694.0, 100.0, 700.0, 500.0)) // track
..rect(rect: const Rect.fromLTRB(694.0, 100.0, 700.0, 121.0)) // thumb
); // 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