Remove single axis assertion (#120738)
This commit is contained in:
@@ -201,6 +201,11 @@ class _GlowingOverscrollIndicatorState extends State<GlowingOverscrollIndicator>
|
||||
if (!widget.notificationPredicate(notification)) {
|
||||
return false;
|
||||
}
|
||||
if (notification.metrics.axis != widget.axis) {
|
||||
// This widget is explicitly configured to one axis. If a notification
|
||||
// from a different axis bubbles up, do nothing.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update the paint offset with the current scroll position. This makes
|
||||
// sure that the glow effect correctly scrolls in line with the current
|
||||
@@ -236,7 +241,6 @@ class _GlowingOverscrollIndicatorState extends State<GlowingOverscrollIndicator>
|
||||
}
|
||||
}
|
||||
assert(controller != null);
|
||||
assert(notification.metrics.axis == widget.axis);
|
||||
if (_accepted[isLeading]!) {
|
||||
if (notification.velocity != 0.0) {
|
||||
assert(notification.dragDetails == null);
|
||||
|
||||
@@ -233,6 +233,35 @@ void main() {
|
||||
expect(painter, doesNotOverscroll);
|
||||
});
|
||||
|
||||
testWidgets('Overscroll ignored from alternate axis', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: ScrollConfiguration(
|
||||
behavior: TestScrollBehaviorNoGlow(),
|
||||
child: GlowingOverscrollIndicator(
|
||||
axisDirection: AxisDirection.right,
|
||||
color: Color(0xFF0000FF),
|
||||
child: CustomScrollView(
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
slivers: <Widget>[
|
||||
SliverToBoxAdapter(child: SizedBox(height: 20.0)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
final RenderObject painter = tester.renderObject(find.byType(CustomPaint));
|
||||
await slowDrag(tester, const Offset(200.0, 200.0), const Offset(0.0, 5.0));
|
||||
expect(painter, doesNotOverscroll);
|
||||
await slowDrag(tester, const Offset(200.0, 200.0), const Offset(0.0, -5.0));
|
||||
expect(painter, doesNotOverscroll);
|
||||
|
||||
await tester.pumpAndSettle(const Duration(seconds: 1));
|
||||
expect(painter, doesNotOverscroll);
|
||||
});
|
||||
|
||||
testWidgets('Overscroll horizontally', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
@@ -570,3 +599,12 @@ class TestScrollBehavior2 extends ScrollBehavior {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TestScrollBehaviorNoGlow extends ScrollBehavior {
|
||||
const TestScrollBehaviorNoGlow();
|
||||
|
||||
@override
|
||||
Widget buildOverscrollIndicator(BuildContext context, Widget child, ScrollableDetails details) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user