@@ -1012,6 +1012,54 @@ void main() {
1012
1012
);
1013
1013
});
1014
1014
1015
+ testWidgets ('Inertia-cancel event does not modify either position.' , (WidgetTester tester) async {
1016
+ final GlobalKey <NestedScrollViewState > globalKey = GlobalKey ();
1017
+ await tester.pumpWidget (buildTest (
1018
+ key: globalKey,
1019
+ expanded: false ,
1020
+ ));
1021
+
1022
+ double appBarHeight = tester.renderObject <RenderBox >(find.byType (AppBar )).size.height;
1023
+ expect (appBarHeight, 104.0 );
1024
+ final double scrollExtent = appBarHeight + 50.0 ;
1025
+ expect (globalKey.currentState! .outerController.offset, 0.0 );
1026
+ expect (globalKey.currentState! .innerController.offset, 0.0 );
1027
+
1028
+ // The scroll gesture should occur in the inner body, so the whole
1029
+ // scroll view is scrolled.
1030
+ final TestGesture gesture = await tester.startGesture (Offset (
1031
+ 0.0 ,
1032
+ appBarHeight + 1.0 ,
1033
+ ));
1034
+ await gesture.moveBy (Offset (0.0 , - scrollExtent));
1035
+ await tester.pump ();
1036
+
1037
+ appBarHeight = tester.renderObject <RenderBox >(find.byType (AppBar )).size.height;
1038
+ // This is not an expanded AppBar.
1039
+ expect (appBarHeight, 104.0 );
1040
+ // The outer scroll controller should show an offset of the applied
1041
+ // scrollExtent.
1042
+ expect (globalKey.currentState! .outerController.offset, appBarHeight);
1043
+ // the inner scroll controller should have scrolled equivalent to the
1044
+ // difference between the applied scrollExtent and the outer extent.
1045
+ expect (
1046
+ globalKey.currentState! .innerController.offset,
1047
+ scrollExtent - appBarHeight,
1048
+ );
1049
+
1050
+ final TestPointer testPointer = TestPointer (3 , ui.PointerDeviceKind .trackpad);
1051
+ await tester.sendEventToBinding (testPointer.addPointer (
1052
+ location: Offset (0.0 , appBarHeight + 1.0 )
1053
+ ));
1054
+ await tester.sendEventToBinding (testPointer.scrollInertiaCancel ());
1055
+ // ensure no change.
1056
+ expect (globalKey.currentState! .outerController.offset, appBarHeight);
1057
+ expect (
1058
+ globalKey.currentState! .innerController.offset,
1059
+ scrollExtent - appBarHeight,
1060
+ );
1061
+ });
1062
+
1015
1063
testWidgets ('scrolling by less than the expanded outer extent does not scroll the inner body' , (WidgetTester tester) async {
1016
1064
final GlobalKey <NestedScrollViewState > globalKey = GlobalKey ();
1017
1065
await tester.pumpWidget (buildTest (key: globalKey));
0 commit comments