@@ -63,6 +63,54 @@ void main() {
63
63
);
64
64
}
65
65
66
+ testWidgets ('Do not crash when replacing scroll position during the drag' , (WidgetTester tester) async {
67
+ // Regression test for https://github.com/flutter/flutter/issues/89681
68
+ bool showScrollbars = false ;
69
+ await tester.pumpWidget (
70
+ Directionality (
71
+ textDirection: TextDirection .ltr,
72
+ child: MediaQuery (
73
+ data: const MediaQueryData (),
74
+ child: Align (
75
+ alignment: Alignment .bottomCenter,
76
+ child: DraggableScrollableSheet (
77
+ initialChildSize: 0.7 ,
78
+ minChildSize: 0.2 ,
79
+ maxChildSize: 0.9 ,
80
+ expand: false ,
81
+ builder: (BuildContext context, ScrollController scrollController) {
82
+ showScrollbars = ! showScrollbars;
83
+ // Change the scroll behavior will trigger scroll position replace.
84
+ final ScrollBehavior behavior = const ScrollBehavior ().copyWith (scrollbars: showScrollbars);
85
+ return ScrollConfiguration (
86
+ behavior: behavior,
87
+ child: ListView .separated (
88
+ physics: const BouncingScrollPhysics (),
89
+ controller: scrollController,
90
+ separatorBuilder: (_, __) => const Divider (),
91
+ itemCount: 100 ,
92
+ itemBuilder: (_, int index) => SizedBox (
93
+ height: 100 ,
94
+ child: ColoredBox (
95
+ color: Colors .primaries[index % Colors .primaries.length],
96
+ child: Text ('Item $index ' ),
97
+ ),
98
+ ),
99
+ ),
100
+ );
101
+ },
102
+ ),
103
+ ),
104
+ ),
105
+ ),
106
+ );
107
+
108
+ await tester.fling (find.text ('Item 1' ), const Offset (0 , 200 ), 350 );
109
+ await tester.pumpAndSettle ();
110
+
111
+ // Go without throw.
112
+ });
113
+
66
114
testWidgets ('Scrolls correct amount when maxChildSize < 1.0' , (WidgetTester tester) async {
67
115
const Key key = ValueKey <String >('container' );
68
116
await tester.pumpWidget (boilerplateWidget (
0 commit comments