Adds mainAxisMargin property to RawScrollbar (#84988)
This commit is contained in:
@@ -863,10 +863,12 @@ class RawScrollbar extends StatefulWidget {
|
||||
this.notificationPredicate = defaultScrollNotificationPredicate,
|
||||
this.interactive,
|
||||
this.scrollbarOrientation,
|
||||
this.mainAxisMargin = 0.0,
|
||||
}) : assert(child != null),
|
||||
assert(fadeDuration != null),
|
||||
assert(timeToFade != null),
|
||||
assert(pressDuration != null),
|
||||
assert(mainAxisMargin != null),
|
||||
super(key: key);
|
||||
|
||||
/// {@template flutter.widgets.Scrollbar.child}
|
||||
@@ -1077,6 +1079,12 @@ class RawScrollbar extends StatefulWidget {
|
||||
/// {@macro flutter.widgets.Scrollbar.scrollbarOrientation}
|
||||
final ScrollbarOrientation? scrollbarOrientation;
|
||||
|
||||
/// Distance from the scrollbar's start and end to the edge of the viewport
|
||||
/// in logical pixels. It affects the amount of available paint area.
|
||||
///
|
||||
/// Mustn't be null and defaults to 0.
|
||||
final double mainAxisMargin;
|
||||
|
||||
@override
|
||||
RawScrollbarState<RawScrollbar> createState() => RawScrollbarState<RawScrollbar>();
|
||||
}
|
||||
@@ -1149,6 +1157,7 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
|
||||
thickness: widget.thickness ?? _kScrollbarThickness,
|
||||
fadeoutOpacityAnimation: _fadeoutOpacityAnimation,
|
||||
scrollbarOrientation: widget.scrollbarOrientation,
|
||||
mainAxisMargin: widget.mainAxisMargin,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1284,7 +1293,8 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
|
||||
..thickness = widget.thickness ?? _kScrollbarThickness
|
||||
..radius = widget.radius
|
||||
..padding = MediaQuery.of(context).padding
|
||||
..scrollbarOrientation = widget.scrollbarOrientation;
|
||||
..scrollbarOrientation = widget.scrollbarOrientation
|
||||
..mainAxisMargin = widget.mainAxisMargin;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -1452,4 +1452,34 @@ void main() {
|
||||
|
||||
expect(() => painter.paint(testCanvas, size), throwsA(isA<AssertionError>()));
|
||||
});
|
||||
|
||||
testWidgets('RawScrollbar mainAxisMargin property works properly', (WidgetTester tester) async {
|
||||
final ScrollController scrollController = ScrollController();
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: RawScrollbar(
|
||||
mainAxisMargin: 10,
|
||||
isAlwaysShown: true,
|
||||
controller: scrollController,
|
||||
child: SingleChildScrollView(
|
||||
controller: scrollController,
|
||||
child: const SizedBox(width: 1000.0, height: 1000.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
expect(scrollController.offset, 0.0);
|
||||
expect(
|
||||
find.byType(RawScrollbar),
|
||||
paints
|
||||
..rect(rect: const Rect.fromLTRB(794.0, 0.0, 800.0, 580.0))
|
||||
..rect(rect: const Rect.fromLTRB(794.0, 10.0, 800.0, 358.0))
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user