@@ -3568,6 +3568,46 @@ void main() {
35683568 expect (tester.getCenter (find.byKey (lastTabKey)).dx, equals (750.0 ));
35693569 });
35703570
3571+ testWidgets ('Do not throw when switching beetween a scrollable TabBar and a non-scrollable TabBar' , (WidgetTester tester) async {
3572+ // This is a regression test for https://github.com/flutter/flutter/issues/120649
3573+ final TabController controller1 = TabController (
3574+ vsync: const TestVSync (),
3575+ length: 2 ,
3576+ );
3577+ final TabController controller2 = TabController (
3578+ vsync: const TestVSync (),
3579+ length: 2 ,
3580+ );
3581+
3582+ Widget buildFrame (TabController controller, bool isScrollable) {
3583+ return boilerplate (
3584+ child: Container (
3585+ alignment: Alignment .topLeft,
3586+ child: TabBar (
3587+ controller: controller,
3588+ isScrollable: isScrollable,
3589+ tabs: const < Tab > [
3590+ Tab (text: 'LEFT' ),
3591+ Tab (text: 'RIGHT' ),
3592+ ],
3593+ ),
3594+ ),
3595+ );
3596+ }
3597+
3598+ // Show both controllers once.
3599+ await tester.pumpWidget (buildFrame (controller1, false ));
3600+ await tester.pumpWidget (buildFrame (controller2, true ));
3601+
3602+ // Switch back to the first controller.
3603+ await tester.pumpWidget (buildFrame (controller1, false ));
3604+ expect (tester.takeException (), null );
3605+
3606+ // Switch back to the second controller.
3607+ await tester.pumpWidget (buildFrame (controller2, true ));
3608+ expect (tester.takeException (), null );
3609+ });
3610+
35713611 testWidgets ('Default tab indicator color is white' , (WidgetTester tester) async {
35723612 // Regression test for https://github.com/flutter/flutter/issues/15958
35733613 final List <String > tabs = < String > ['LEFT' , 'RIGHT' ];
0 commit comments