Unverified Commit 94f9a280 authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

Revert "Added AxisOrientation property to Scrollbar (#75497)" (#82753)

This reverts commit 4a720313.
parent 4a720313
...@@ -62,7 +62,6 @@ class CupertinoScrollbar extends RawScrollbar { ...@@ -62,7 +62,6 @@ class CupertinoScrollbar extends RawScrollbar {
Radius radius = defaultRadius, Radius radius = defaultRadius,
this.radiusWhileDragging = defaultRadiusWhileDragging, this.radiusWhileDragging = defaultRadiusWhileDragging,
ScrollNotificationPredicate? notificationPredicate, ScrollNotificationPredicate? notificationPredicate,
ScrollbarOrientation? scrollbarOrientation,
}) : assert(thickness != null), }) : assert(thickness != null),
assert(thickness < double.infinity), assert(thickness < double.infinity),
assert(thicknessWhileDragging != null), assert(thicknessWhileDragging != null),
...@@ -80,7 +79,6 @@ class CupertinoScrollbar extends RawScrollbar { ...@@ -80,7 +79,6 @@ class CupertinoScrollbar extends RawScrollbar {
timeToFade: _kScrollbarTimeToFade, timeToFade: _kScrollbarTimeToFade,
pressDuration: const Duration(milliseconds: 100), pressDuration: const Duration(milliseconds: 100),
notificationPredicate: notificationPredicate ?? defaultScrollNotificationPredicate, notificationPredicate: notificationPredicate ?? defaultScrollNotificationPredicate,
scrollbarOrientation: scrollbarOrientation,
); );
/// Default value for [thickness] if it's not specified in [CupertinoScrollbar]. /// Default value for [thickness] if it's not specified in [CupertinoScrollbar].
...@@ -150,8 +148,7 @@ class _CupertinoScrollbarState extends RawScrollbarState<CupertinoScrollbar> { ...@@ -150,8 +148,7 @@ class _CupertinoScrollbarState extends RawScrollbarState<CupertinoScrollbar> {
..radius = _radius ..radius = _radius
..padding = MediaQuery.of(context).padding ..padding = MediaQuery.of(context).padding
..minLength = _kScrollbarMinLength ..minLength = _kScrollbarMinLength
..minOverscrollLength = _kScrollbarMinOverscrollLength ..minOverscrollLength = _kScrollbarMinOverscrollLength;
..scrollbarOrientation = widget.scrollbarOrientation;
} }
double _pressStartAxisPosition = 0.0; double _pressStartAxisPosition = 0.0;
......
...@@ -117,7 +117,6 @@ class Scrollbar extends StatefulWidget { ...@@ -117,7 +117,6 @@ class Scrollbar extends StatefulWidget {
this.radius, this.radius,
this.notificationPredicate, this.notificationPredicate,
this.interactive, this.interactive,
this.scrollbarOrientation,
}) : super(key: key); }) : super(key: key);
/// {@macro flutter.widgets.Scrollbar.child} /// {@macro flutter.widgets.Scrollbar.child}
...@@ -166,9 +165,6 @@ class Scrollbar extends StatefulWidget { ...@@ -166,9 +165,6 @@ class Scrollbar extends StatefulWidget {
/// {@macro flutter.widgets.Scrollbar.notificationPredicate} /// {@macro flutter.widgets.Scrollbar.notificationPredicate}
final ScrollNotificationPredicate? notificationPredicate; final ScrollNotificationPredicate? notificationPredicate;
/// {@macro flutter.widgets.Scrollbar.scrollbarOrientation}
final ScrollbarOrientation? scrollbarOrientation;
@override @override
State<Scrollbar> createState() => _ScrollbarState(); State<Scrollbar> createState() => _ScrollbarState();
} }
...@@ -187,7 +183,6 @@ class _ScrollbarState extends State<Scrollbar> { ...@@ -187,7 +183,6 @@ class _ScrollbarState extends State<Scrollbar> {
radiusWhileDragging: widget.radius ?? CupertinoScrollbar.defaultRadiusWhileDragging, radiusWhileDragging: widget.radius ?? CupertinoScrollbar.defaultRadiusWhileDragging,
controller: widget.controller, controller: widget.controller,
notificationPredicate: widget.notificationPredicate, notificationPredicate: widget.notificationPredicate,
scrollbarOrientation: widget.scrollbarOrientation,
child: widget.child, child: widget.child,
); );
} }
...@@ -200,7 +195,6 @@ class _ScrollbarState extends State<Scrollbar> { ...@@ -200,7 +195,6 @@ class _ScrollbarState extends State<Scrollbar> {
radius: widget.radius, radius: widget.radius,
notificationPredicate: widget.notificationPredicate, notificationPredicate: widget.notificationPredicate,
interactive: widget.interactive, interactive: widget.interactive,
scrollbarOrientation: widget.scrollbarOrientation,
child: widget.child, child: widget.child,
); );
} }
...@@ -218,7 +212,6 @@ class _MaterialScrollbar extends RawScrollbar { ...@@ -218,7 +212,6 @@ class _MaterialScrollbar extends RawScrollbar {
Radius? radius, Radius? radius,
ScrollNotificationPredicate? notificationPredicate, ScrollNotificationPredicate? notificationPredicate,
bool? interactive, bool? interactive,
ScrollbarOrientation? scrollbarOrientation,
}) : super( }) : super(
key: key, key: key,
child: child, child: child,
...@@ -231,7 +224,6 @@ class _MaterialScrollbar extends RawScrollbar { ...@@ -231,7 +224,6 @@ class _MaterialScrollbar extends RawScrollbar {
pressDuration: Duration.zero, pressDuration: Duration.zero,
notificationPredicate: notificationPredicate ?? defaultScrollNotificationPredicate, notificationPredicate: notificationPredicate ?? defaultScrollNotificationPredicate,
interactive: interactive, interactive: interactive,
scrollbarOrientation: scrollbarOrientation,
); );
final bool? showTrackOnHover; final bool? showTrackOnHover;
...@@ -388,8 +380,7 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> { ...@@ -388,8 +380,7 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> {
..crossAxisMargin = _scrollbarTheme.crossAxisMargin ?? (_useAndroidScrollbar ? 0.0 : _kScrollbarMargin) ..crossAxisMargin = _scrollbarTheme.crossAxisMargin ?? (_useAndroidScrollbar ? 0.0 : _kScrollbarMargin)
..mainAxisMargin = _scrollbarTheme.mainAxisMargin ?? 0.0 ..mainAxisMargin = _scrollbarTheme.mainAxisMargin ?? 0.0
..minLength = _scrollbarTheme.minThumbLength ?? _kScrollbarMinLength ..minLength = _scrollbarTheme.minThumbLength ?? _kScrollbarMinLength
..padding = MediaQuery.of(context).padding ..padding = MediaQuery.of(context).padding;
..scrollbarOrientation = widget.scrollbarOrientation;
} }
@override @override
......
...@@ -29,21 +29,6 @@ const double _kScrollbarThickness = 6.0; ...@@ -29,21 +29,6 @@ const double _kScrollbarThickness = 6.0;
const Duration _kScrollbarFadeDuration = Duration(milliseconds: 300); const Duration _kScrollbarFadeDuration = Duration(milliseconds: 300);
const Duration _kScrollbarTimeToFade = Duration(milliseconds: 600); const Duration _kScrollbarTimeToFade = Duration(milliseconds: 600);
/// An orientation along either the horizontal or vertical [Axis].
enum ScrollbarOrientation {
/// Place towards the left of the screen.
left,
/// Place towards the right of the screen.
right,
/// Place on top of the screen.
top,
/// Place on the bottom of the screen.
bottom,
}
/// Paints a scrollbar's track and thumb. /// Paints a scrollbar's track and thumb.
/// ///
/// The size of the scrollbar along its scroll direction is typically /// The size of the scrollbar along its scroll direction is typically
...@@ -87,7 +72,6 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter { ...@@ -87,7 +72,6 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter {
Radius? radius, Radius? radius,
double minLength = _kMinThumbExtent, double minLength = _kMinThumbExtent,
double? minOverscrollLength, double? minOverscrollLength,
ScrollbarOrientation? scrollbarOrientation,
}) : assert(color != null), }) : assert(color != null),
assert(thickness != null), assert(thickness != null),
assert(fadeoutOpacityAnimation != null), assert(fadeoutOpacityAnimation != null),
...@@ -109,7 +93,6 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter { ...@@ -109,7 +93,6 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter {
_minLength = minLength, _minLength = minLength,
_trackColor = trackColor, _trackColor = trackColor,
_trackBorderColor = trackBorderColor, _trackBorderColor = trackBorderColor,
_scrollbarOrientation = scrollbarOrientation,
_minOverscrollLength = minOverscrollLength ?? minLength { _minOverscrollLength = minOverscrollLength ?? minLength {
fadeoutOpacityAnimation.addListener(notifyListeners); fadeoutOpacityAnimation.addListener(notifyListeners);
} }
...@@ -287,46 +270,6 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter { ...@@ -287,46 +270,6 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter {
notifyListeners(); notifyListeners();
} }
/// {@template flutter.widgets.Scrollbar.scrollbarOrientation}
/// Dictates the orientation of the scrollbar.
///
/// [ScrollbarOrientation.top] places the scrollbar on top of the screen.
/// [ScrollbarOrientation.bottom] places the scrollbar on the bottom of the screen.
/// [ScrollbarOrientation.left] places the scrollbar on the left of the screen.
/// [ScrollbarOrientation.right] places the scrollbar on the right of the screen.
///
/// [ScrollbarOrientation.top] and [ScrollbarOrientation.bottom] can only be
/// used with a vertical scroll.
/// [ScrollbarOrientation.left] and [ScrollbarOrientation.right] can only be
/// used with a horizontal scroll.
///
/// For a vertical scroll the orientation defaults to
/// [ScrollbarOrientation.right] for [TextDirection.ltr] and
/// [ScrollbarOrientation.left] for [TextDirection.rtl].
/// For a horizontal scroll the orientation defaults to [ScrollbarOrientation.bottom].
/// {@endtemplate}
ScrollbarOrientation? get scrollbarOrientation => _scrollbarOrientation;
ScrollbarOrientation? _scrollbarOrientation;
set scrollbarOrientation(ScrollbarOrientation? value) {
if (scrollbarOrientation == value)
return;
_scrollbarOrientation = value;
notifyListeners();
}
void _debugAssertIsValidOrientation(ScrollbarOrientation orientation) {
assert(
(_isVertical && _isVerticalOrientation(orientation)) || (!_isVertical && !_isVerticalOrientation(orientation)),
'The given ScrollbarOrientation: $orientation is incompatible with the current AxisDirection: $_lastAxisDirection.'
);
}
/// Check whether given scrollbar orientation is vertical
bool _isVerticalOrientation(ScrollbarOrientation orientation) =>
orientation == ScrollbarOrientation.left
|| orientation == ScrollbarOrientation.right;
ScrollMetrics? _lastMetrics; ScrollMetrics? _lastMetrics;
AxisDirection? _lastAxisDirection; AxisDirection? _lastAxisDirection;
Rect? _thumbRect; Rect? _thumbRect;
...@@ -374,48 +317,37 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter { ...@@ -374,48 +317,37 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter {
'A TextDirection must be provided before a Scrollbar can be painted.', 'A TextDirection must be provided before a Scrollbar can be painted.',
); );
final ScrollbarOrientation resolvedOrientation;
if (scrollbarOrientation == null) {
if (_isVertical)
resolvedOrientation = textDirection == TextDirection.ltr
? ScrollbarOrientation.right
: ScrollbarOrientation.left;
else
resolvedOrientation = ScrollbarOrientation.bottom;
}
else {
resolvedOrientation = scrollbarOrientation!;
}
final double x, y; final double x, y;
final Size thumbSize, trackSize; final Size thumbSize, trackSize;
final Offset trackOffset; final Offset trackOffset;
_debugAssertIsValidOrientation(resolvedOrientation); switch (direction) {
switch(resolvedOrientation) { case AxisDirection.down:
case ScrollbarOrientation.left:
thumbSize = Size(thickness, thumbExtent); thumbSize = Size(thickness, thumbExtent);
trackSize = Size(thickness + 2 * crossAxisMargin, _trackExtent); trackSize = Size(thickness + 2 * crossAxisMargin, _trackExtent);
x = crossAxisMargin + padding.left; x = textDirection == TextDirection.rtl
? crossAxisMargin + padding.left
: size.width - thickness - crossAxisMargin - padding.right;
y = _thumbOffset; y = _thumbOffset;
trackOffset = Offset(x - crossAxisMargin, 0.0); trackOffset = Offset(x - crossAxisMargin, 0.0);
break; break;
case ScrollbarOrientation.right: case AxisDirection.up:
thumbSize = Size(thickness, thumbExtent); thumbSize = Size(thickness, thumbExtent);
trackSize = Size(thickness + 2 * crossAxisMargin, _trackExtent); trackSize = Size(thickness + 2 * crossAxisMargin, _trackExtent);
x = size.width - thickness - crossAxisMargin - padding.right; x = textDirection == TextDirection.rtl
? crossAxisMargin + padding.left
: size.width - thickness - crossAxisMargin - padding.right;
y = _thumbOffset; y = _thumbOffset;
trackOffset = Offset(x - crossAxisMargin, 0.0); trackOffset = Offset(x - crossAxisMargin, 0.0);
break; break;
case ScrollbarOrientation.top: case AxisDirection.left:
thumbSize = Size(thumbExtent, thickness); thumbSize = Size(thumbExtent, thickness);
trackSize = Size(_trackExtent, thickness + 2 * crossAxisMargin);
x = _thumbOffset; x = _thumbOffset;
y = crossAxisMargin + padding.top; y = size.height - thickness - crossAxisMargin - padding.bottom;
trackSize = Size(_trackExtent, thickness + 2 * crossAxisMargin);
trackOffset = Offset(0.0, y - crossAxisMargin); trackOffset = Offset(0.0, y - crossAxisMargin);
break; break;
case ScrollbarOrientation.bottom: case AxisDirection.right:
thumbSize = Size(thumbExtent, thickness); thumbSize = Size(thumbExtent, thickness);
trackSize = Size(_trackExtent, thickness + 2 * crossAxisMargin); trackSize = Size(_trackExtent, thickness + 2 * crossAxisMargin);
x = _thumbOffset; x = _thumbOffset;
...@@ -638,8 +570,7 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter { ...@@ -638,8 +570,7 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter {
|| radius != old.radius || radius != old.radius
|| minLength != old.minLength || minLength != old.minLength
|| padding != old.padding || padding != old.padding
|| minOverscrollLength != old.minOverscrollLength || minOverscrollLength != old.minOverscrollLength;
|| scrollbarOrientation != old.scrollbarOrientation;
} }
@override @override
...@@ -724,7 +655,6 @@ class RawScrollbar extends StatefulWidget { ...@@ -724,7 +655,6 @@ class RawScrollbar extends StatefulWidget {
this.pressDuration = Duration.zero, this.pressDuration = Duration.zero,
this.notificationPredicate = defaultScrollNotificationPredicate, this.notificationPredicate = defaultScrollNotificationPredicate,
this.interactive, this.interactive,
this.scrollbarOrientation,
}) : assert(child != null), }) : assert(child != null),
assert(fadeDuration != null), assert(fadeDuration != null),
assert(timeToFade != null), assert(timeToFade != null),
...@@ -936,9 +866,6 @@ class RawScrollbar extends StatefulWidget { ...@@ -936,9 +866,6 @@ class RawScrollbar extends StatefulWidget {
/// {@endtemplate} /// {@endtemplate}
final bool? interactive; final bool? interactive;
/// {@macro flutter.widgets.Scrollbar.scrollbarOrientation}
final ScrollbarOrientation? scrollbarOrientation;
@override @override
RawScrollbarState<RawScrollbar> createState() => RawScrollbarState<RawScrollbar>(); RawScrollbarState<RawScrollbar> createState() => RawScrollbarState<RawScrollbar>();
} }
...@@ -1010,7 +937,6 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv ...@@ -1010,7 +937,6 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
color: widget.thumbColor ?? const Color(0x66BCBCBC), color: widget.thumbColor ?? const Color(0x66BCBCBC),
thickness: widget.thickness ?? _kScrollbarThickness, thickness: widget.thickness ?? _kScrollbarThickness,
fadeoutOpacityAnimation: _fadeoutOpacityAnimation, fadeoutOpacityAnimation: _fadeoutOpacityAnimation,
scrollbarOrientation: widget.scrollbarOrientation,
); );
} }
...@@ -1116,8 +1042,7 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv ...@@ -1116,8 +1042,7 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
..textDirection = Directionality.of(context) ..textDirection = Directionality.of(context)
..thickness = widget.thickness ?? _kScrollbarThickness ..thickness = widget.thickness ?? _kScrollbarThickness
..radius = widget.radius ..radius = widget.radius
..padding = MediaQuery.of(context).padding ..padding = MediaQuery.of(context).padding;
..scrollbarOrientation = widget.scrollbarOrientation;
} }
@override @override
......
...@@ -889,43 +889,4 @@ void main() { ...@@ -889,43 +889,4 @@ void main() {
), ),
); );
}); });
testWidgets('CupertinoScrollbar scrollOrientation works correctly', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController();
await tester.pumpWidget(
CupertinoApp(
home: PrimaryScrollController(
controller: scrollController,
child: CupertinoScrollbar(
isAlwaysShown: true,
controller: scrollController,
scrollbarOrientation: ScrollbarOrientation.left,
child: const SingleChildScrollView(
child: SizedBox(width: 4000.0, height: 4000.0),
),
),
),
),
);
await tester.pumpAndSettle();
expect(
find.byType(CupertinoScrollbar),
paints
..rect(
rect: const Rect.fromLTRB(0.0, 0.0, 9.0, 594.0),
)
..line(
p1: const Offset(0.0, 0.0),
p2: const Offset(0.0, 594.0),
strokeWidth: 1.0,
)
..rrect(
rrect: RRect.fromRectAndRadius(const Rect.fromLTRB(3.0, 3.0, 6.0, 92.1), const Radius.circular(1.5)),
color: _kScrollbarColor.color,
),
);
});
} }
...@@ -1492,52 +1492,4 @@ void main() { ...@@ -1492,52 +1492,4 @@ void main() {
); );
} }
}); });
testWidgets('Scrollbar scrollOrientation works correctly', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController();
Widget _buildScrollWithOrientation(ScrollbarOrientation orientation) {
return _buildBoilerplate(
child: Theme(
data: ThemeData(
platform: TargetPlatform.android,
),
child: PrimaryScrollController(
controller: scrollController,
child: Scrollbar(
interactive: true,
isAlwaysShown: true,
scrollbarOrientation: orientation,
controller: scrollController,
child: const SingleChildScrollView(
child: SizedBox(width: 4000.0, height: 4000.0)
),
),
),
)
);
}
await tester.pumpWidget(_buildScrollWithOrientation(ScrollbarOrientation.left));
await tester.pumpAndSettle();
expect(
find.byType(Scrollbar),
paints
..rect(
rect: const Rect.fromLTRB(0.0, 0.0, 4.0, 600.0),
color: Colors.transparent,
)
..line(
p1: const Offset(0.0, 0.0),
p2: const Offset(0.0, 600.0),
strokeWidth: 1.0,
color: Colors.transparent,
)
..rect(
rect: const Rect.fromLTRB(0.0, 0.0, 4.0, 90.0),
color: _kAndroidThumbIdleColor,
),
);
});
} }
...@@ -26,7 +26,6 @@ ScrollbarPainter _buildPainter({ ...@@ -26,7 +26,6 @@ ScrollbarPainter _buildPainter({
Radius? radius, Radius? radius,
double minLength = _kMinThumbExtent, double minLength = _kMinThumbExtent,
double? minOverscrollLength, double? minOverscrollLength,
ScrollbarOrientation? scrollbarOrientation,
required ScrollMetrics scrollMetrics, required ScrollMetrics scrollMetrics,
}) { }) {
return ScrollbarPainter( return ScrollbarPainter(
...@@ -40,7 +39,6 @@ ScrollbarPainter _buildPainter({ ...@@ -40,7 +39,6 @@ ScrollbarPainter _buildPainter({
minLength: minLength, minLength: minLength,
minOverscrollLength: minOverscrollLength ?? minLength, minOverscrollLength: minOverscrollLength ?? minLength,
fadeoutOpacityAnimation: kAlwaysCompleteAnimation, fadeoutOpacityAnimation: kAlwaysCompleteAnimation,
scrollbarOrientation: scrollbarOrientation,
)..update(scrollMetrics, scrollMetrics.axisDirection); )..update(scrollMetrics, scrollMetrics.axisDirection);
} }
...@@ -250,128 +248,6 @@ void main() { ...@@ -250,128 +248,6 @@ void main() {
}, },
); );
test('scrollbarOrientation are respected', () {
const double viewportDimension = 23;
const double maxExtent = 100;
final ScrollMetrics startingMetrics = defaultMetrics.copyWith(
maxScrollExtent: maxExtent,
viewportDimension: viewportDimension,
);
const Size size = Size(600, viewportDimension);
const double margin = 0;
for (final ScrollbarOrientation scrollbarOrientation in ScrollbarOrientation.values) {
final AxisDirection axisDirection;
if (scrollbarOrientation == ScrollbarOrientation.left || scrollbarOrientation == ScrollbarOrientation.right)
axisDirection = AxisDirection.down;
else
axisDirection = AxisDirection.right;
painter = _buildPainter(
crossAxisMargin: margin,
scrollMetrics: startingMetrics,
scrollbarOrientation: scrollbarOrientation,
);
painter.update(
startingMetrics.copyWith(axisDirection: axisDirection),
axisDirection
);
painter.paint(testCanvas, size);
final Rect rect = captureRect();
switch (scrollbarOrientation) {
case ScrollbarOrientation.left:
expect(rect.left, 0);
expect(rect.top, 0);
expect(rect.right, _kThickness);
expect(rect.bottom, _kMinThumbExtent);
break;
case ScrollbarOrientation.right:
expect(rect.left, 600 - _kThickness);
expect(rect.top, 0);
expect(rect.right, 600);
expect(rect.bottom, _kMinThumbExtent);
break;
case ScrollbarOrientation.top:
expect(rect.left, 0);
expect(rect.top, 0);
expect(rect.right, _kMinThumbExtent);
expect(rect.bottom, _kThickness);
break;
case ScrollbarOrientation.bottom:
expect(rect.left, 0);
expect(rect.top, 23 - _kThickness);
expect(rect.right, _kMinThumbExtent);
expect(rect.bottom, 23);
break;
}
}
});
test('scrollbarOrientation default values are correct', () {
const double viewportDimension = 23;
const double maxExtent = 100;
final ScrollMetrics startingMetrics = defaultMetrics.copyWith(
maxScrollExtent: maxExtent,
viewportDimension: viewportDimension,
);
const Size size = Size(600, viewportDimension);
const double margin = 0;
Rect rect;
// Vertical scroll with TextDirection.ltr
painter = _buildPainter(
crossAxisMargin: margin,
scrollMetrics: startingMetrics,
textDirection: TextDirection.ltr,
);
painter.update(
startingMetrics.copyWith(axisDirection: AxisDirection.down),
AxisDirection.down
);
painter.paint(testCanvas, size);
rect = captureRect();
expect(rect.left, 600 - _kThickness);
expect(rect.top, 0);
expect(rect.right, 600);
expect(rect.bottom, _kMinThumbExtent);
// Vertical scroll with TextDirection.rtl
painter = _buildPainter(
crossAxisMargin: margin,
scrollMetrics: startingMetrics,
textDirection: TextDirection.rtl,
);
painter.update(
startingMetrics.copyWith(axisDirection: AxisDirection.down),
AxisDirection.down
);
painter.paint(testCanvas, size);
rect = captureRect();
expect(rect.left, 0);
expect(rect.top, 0);
expect(rect.right, _kThickness);
expect(rect.bottom, _kMinThumbExtent);
// Horizontal scroll
painter = _buildPainter(
crossAxisMargin: margin,
scrollMetrics: startingMetrics,
);
painter.update(
startingMetrics.copyWith(axisDirection: AxisDirection.right),
AxisDirection.right,
);
painter.paint(testCanvas, size);
rect = captureRect();
expect(rect.left, 0);
expect(rect.top, 23 - _kThickness);
expect(rect.right, _kMinThumbExtent);
expect(rect.bottom, 23);
});
group('Padding works for all scroll directions', () { group('Padding works for all scroll directions', () {
const EdgeInsets padding = EdgeInsets.fromLTRB(1, 2, 3, 4); const EdgeInsets padding = EdgeInsets.fromLTRB(1, 2, 3, 4);
const Size size = Size(60, 80); const Size size = Size(60, 80);
...@@ -1338,22 +1214,4 @@ void main() { ...@@ -1338,22 +1214,4 @@ void main() {
), ),
); );
}); });
testWidgets('ScrollbarPainter asserts if scrollbarOrientation is used with wrong axisDirection', (WidgetTester tester) async {
final ScrollbarPainter painter = ScrollbarPainter(
color: _kScrollbarColor,
fadeoutOpacityAnimation: kAlwaysCompleteAnimation,
textDirection: TextDirection.ltr,
scrollbarOrientation: ScrollbarOrientation.left,
);
const Size size = Size(60, 80);
final ScrollMetrics scrollMetrics = defaultMetrics.copyWith(
maxScrollExtent: 100,
viewportDimension: size.height,
axisDirection: AxisDirection.right,
);
painter.update(scrollMetrics, scrollMetrics.axisDirection);
expect(() => painter.paint(testCanvas, size), throwsA(isA<AssertionError>()));
});
} }
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