@@ -7158,4 +7158,96 @@ void main() {
7158
7158
labelSize = tester.getSize (find.text ('Tab 1' ));
7159
7159
expect (labelSize, equals (const Size (140.5 , 40.0 )));
7160
7160
}, skip: isBrowser && ! isSkiaWeb); // https://github.com/flutter/flutter/issues/87543
7161
+
7162
+ // This is a regression test for https://github.com/flutter/flutter/issues/150000.
7163
+ testWidgets ('Scrollable TabBar does not jitter in the middle position' , (WidgetTester tester) async {
7164
+ final List <String > tabs = List <String >.generate (20 , (int index) => 'Tab $index ' );
7165
+
7166
+ await tester.pumpWidget (MaterialApp (
7167
+ home: DefaultTabController (
7168
+ length: tabs.length,
7169
+ initialIndex: 10 ,
7170
+ child: Scaffold (
7171
+ appBar: AppBar (
7172
+ bottom: TabBar (
7173
+ isScrollable: true ,
7174
+ tabs: tabs.map ((String tab) => Tab (text: tab)).toList (),
7175
+ ),
7176
+ ),
7177
+ body: TabBarView (
7178
+ children: < Widget > [
7179
+ for (int i = 0 ; i < tabs.length; i++ )
7180
+ Center (
7181
+ child: Text ('Page $i ' ),
7182
+ ),
7183
+ ],
7184
+ ),
7185
+ ),
7186
+ ),
7187
+ ));
7188
+
7189
+ final SingleChildScrollView scrollable = tester.widget (find.byType (SingleChildScrollView ));
7190
+ expect (find.text ('Page 10' ), findsOneWidget);
7191
+ expect (find.text ('Page 11' ), findsNothing);
7192
+ expect (scrollable.controller! .position.pixels, closeTo (683.2 , 0.1 ));
7193
+
7194
+ // Drag the TabBarView to the left.
7195
+ await tester.drag (find.byType (TabBarView ), const Offset (- 800 , 0 ));
7196
+ await tester.pump ();
7197
+ await tester.pump (const Duration (milliseconds: 200 ));
7198
+
7199
+ expect (find.text ('Page 10' ), findsNothing);
7200
+ expect (find.text ('Page 11' ), findsOneWidget);
7201
+ expect (scrollable.controller! .position.pixels, closeTo (799.8 , 0.1 ));
7202
+ });
7203
+
7204
+ // This is a regression test for https://github.com/flutter/flutter/issues/150000.
7205
+ testWidgets ('Scrollable TabBar does not jitter when the tab bar reaches the start' , (WidgetTester tester) async {
7206
+ final List <String > tabs = List <String >.generate (20 , (int index) => 'Tab $index ' );
7207
+
7208
+ await tester.pumpWidget (MaterialApp (
7209
+ home: DefaultTabController (
7210
+ length: tabs.length,
7211
+ initialIndex: 4 ,
7212
+ child: Scaffold (
7213
+ appBar: AppBar (
7214
+ bottom: TabBar (
7215
+ isScrollable: true ,
7216
+ tabs: tabs.map ((String tab) => Tab (text: tab)).toList (),
7217
+ ),
7218
+ ),
7219
+ body: TabBarView (
7220
+ children: < Widget > [
7221
+ for (int i = 0 ; i < tabs.length; i++ )
7222
+ Center (
7223
+ child: Text ('Page $i ' ),
7224
+ ),
7225
+ ],
7226
+ ),
7227
+ ),
7228
+ ),
7229
+ ));
7230
+
7231
+ final SingleChildScrollView scrollable = tester.widget (find.byType (SingleChildScrollView ));
7232
+
7233
+ expect (find.text ('Page 4' ), findsOneWidget);
7234
+ expect (find.text ('Page 3' ), findsNothing);
7235
+ expect (scrollable.controller! .position.pixels, closeTo (61.25 , 0.1 ));
7236
+
7237
+ // Drag the TabBarView to the right.
7238
+ final TestGesture gesture = await tester.startGesture (tester.getCenter (find.text ('Page 4' )));
7239
+ await gesture.moveBy (const Offset (600.0 , 0.0 ));
7240
+ await gesture.up ();
7241
+ await tester.pump ();
7242
+ await tester.pump (const Duration (milliseconds: 500 ));
7243
+
7244
+ expect (find.text ('Page 4' ), findsOneWidget);
7245
+ expect (find.text ('Page 3' ), findsOneWidget);
7246
+ expect (scrollable.controller! .position.pixels, closeTo (0.2 , 0.1 ));
7247
+
7248
+ await tester.pumpAndSettle ();
7249
+ expect (find.text ('Page 4' ), findsNothing);
7250
+ expect (find.text ('Page 3' ), findsOneWidget);
7251
+ expect (scrollable.controller! .position.pixels, equals (0.0 ));
7252
+ });
7161
7253
}
0 commit comments