From 26c36623b2b019a5c5d46e772d393e528e2a4458 Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Mon, 27 Mar 2017 16:31:28 -0700 Subject: [PATCH] Added a TabBar regression test (#9038) --- packages/flutter/test/material/tabs_test.dart | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/flutter/test/material/tabs_test.dart b/packages/flutter/test/material/tabs_test.dart index 5f719b0e81..09ee174ec0 100644 --- a/packages/flutter/test/material/tabs_test.dart +++ b/packages/flutter/test/material/tabs_test.dart @@ -730,4 +730,33 @@ void main() { expect(indicatorRect2.width, 400.0); expect(indicatorRect2.height, 2.0); }); + + testWidgets('TabBarView child disposed during animation', (WidgetTester tester) async { + // This is a regression test for this patch: + // https://github.com/flutter/flutter/pull/9015 + + final TabController controller = new TabController( + vsync: const TestVSync(), + length: 2, + ); + + Widget buildFrame() { + return new Material( + child: new TabBar( + key: new UniqueKey(), + controller: controller, + tabs: [ new Text('A'), new Text('B') ], + ), + ); + } + + await tester.pumpWidget(buildFrame()); + + // The original TabBar will be disposed. The controller should no + // longer have any listeners from the original TabBar. + await tester.pumpWidget(buildFrame()); + + controller.index = 1; + await tester.pump(const Duration(milliseconds: 300)); + }); }