@@ -78,6 +78,65 @@ void main() {
7878 );
7979 }
8080
81+ testWidgets ('Stretch overscroll will do nothing when axes do not match' , (WidgetTester tester) async {
82+ final GlobalKey box1Key = GlobalKey ();
83+ final GlobalKey box2Key = GlobalKey ();
84+ final ScrollController controller = ScrollController ();
85+ await tester.pumpWidget (
86+ Directionality (
87+ textDirection: TextDirection .ltr,
88+ child: MediaQuery (
89+ data: const MediaQueryData (size: Size (800.0 , 600.0 )),
90+ child: ScrollConfiguration (
91+ behavior: const ScrollBehavior ().copyWith (overscroll: false ),
92+ child: StretchingOverscrollIndicator (
93+ axisDirection: AxisDirection .right,
94+ child: CustomScrollView (
95+ controller: controller,
96+ slivers: < Widget > [
97+ SliverToBoxAdapter (child: Container (
98+ color: const Color (0xD0FF0000 ),
99+ key: box1Key,
100+ height: 250.0 ,
101+ )),
102+ SliverToBoxAdapter (child: Container (
103+ color: const Color (0xFFFFFF00 ),
104+ key: box2Key,
105+ height: 250.0 ,
106+ width: 300.0 ,
107+ )),
108+ ],
109+ ),
110+ ),
111+ ),
112+ ),
113+ )
114+ );
115+
116+ expect (find.byType (StretchingOverscrollIndicator ), findsOneWidget);
117+ expect (find.byType (GlowingOverscrollIndicator ), findsNothing);
118+ final RenderBox box1 = tester.renderObject (find.byKey (box1Key));
119+ final RenderBox box2 = tester.renderObject (find.byKey (box2Key));
120+
121+ expect (controller.offset, 0.0 );
122+ expect (box1.localToGlobal (Offset .zero), Offset .zero);
123+ expect (box2.localToGlobal (Offset .zero), const Offset (0.0 , 250.0 ));
124+
125+ final TestGesture gesture = await tester.startGesture (tester.getCenter (find.byType (CustomScrollView )));
126+ // Overscroll the start, no stretching occurs.
127+ await gesture.moveBy (const Offset (0.0 , 200.0 ));
128+ await tester.pumpAndSettle ();
129+ expect (box1.localToGlobal (Offset .zero), Offset .zero);
130+ expect (box2.localToGlobal (Offset .zero).dy, 250.0 );
131+
132+ await gesture.up ();
133+ await tester.pumpAndSettle ();
134+
135+ // Overscroll released
136+ expect (box1.localToGlobal (Offset .zero), Offset .zero);
137+ expect (box2.localToGlobal (Offset .zero), const Offset (0.0 , 250.0 ));
138+ });
139+
81140 testWidgets ('Stretch overscroll vertically' , (WidgetTester tester) async {
82141 final GlobalKey box1Key = GlobalKey ();
83142 final GlobalKey box2Key = GlobalKey ();
0 commit comments