diff --git a/packages/flutter/test/material/app_bar_test.dart b/packages/flutter/test/material/app_bar_test.dart index af1ee49ad6..e32a962de3 100644 --- a/packages/flutter/test/material/app_bar_test.dart +++ b/packages/flutter/test/material/app_bar_test.dart @@ -7,6 +7,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; import '../widgets/semantics_tester.dart'; @@ -81,7 +82,7 @@ void main() { debugResetSemanticsIdCounter(); }); - testWidgets('AppBar centers title on iOS', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar centers title on iOS', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( theme: ThemeData(platform: TargetPlatform.android), @@ -162,7 +163,7 @@ void main() { } }); - testWidgets('AppBar centerTitle:true centers on Android', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar centerTitle:true centers on Android', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( theme: ThemeData(platform: TargetPlatform.android), @@ -182,7 +183,7 @@ void main() { expect(center.dx, lessThan(400 + size.width / 2.0)); }); - testWidgets('AppBar centerTitle:false title start edge is 16.0 (LTR)', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar centerTitle:false title start edge is 16.0 (LTR)', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: Scaffold( @@ -199,7 +200,7 @@ void main() { expect(tester.getTopRight(titleWidget).dx, 800 - 16.0); }); - testWidgets('AppBar centerTitle:false title start edge is 16.0 (RTL)', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar centerTitle:false title start edge is 16.0 (RTL)', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: Directionality( @@ -219,7 +220,7 @@ void main() { expect(tester.getTopLeft(titleWidget).dx, 16.0); }); - testWidgets('AppBar titleSpacing:32 title start edge is 32.0 (LTR)', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar titleSpacing:32 title start edge is 32.0 (LTR)', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: Scaffold( @@ -237,7 +238,7 @@ void main() { expect(tester.getTopRight(titleWidget).dx, 800 - 32.0); }); - testWidgets('AppBar titleSpacing:32 title start edge is 32.0 (RTL)', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar titleSpacing:32 title start edge is 32.0 (RTL)', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: Directionality( @@ -258,7 +259,7 @@ void main() { expect(tester.getTopLeft(titleWidget).dx, 32.0); }); - testWidgets( + testWidgetsWithLeakTracking( 'AppBar centerTitle:false leading button title left edge is 72.0 (LTR)', (WidgetTester tester) async { await tester.pumpWidget( @@ -278,7 +279,7 @@ void main() { }, ); - testWidgets( + testWidgetsWithLeakTracking( 'AppBar centerTitle:false leading button title left edge is 72.0 (RTL)', (WidgetTester tester) async { await tester.pumpWidget( @@ -301,7 +302,7 @@ void main() { }, ); - testWidgets('AppBar centerTitle:false title overflow OK', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar centerTitle:false title overflow OK', (WidgetTester tester) async { // The app bar's title should be constrained to fit within the available space // between the leading and actions widgets. @@ -362,7 +363,7 @@ void main() { expect(tester.getSize(title).width, equals(800.0 - 56.0 - 16.0 - 16.0 - 200.0)); }); - testWidgets('AppBar centerTitle:true title overflow OK (LTR)', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar centerTitle:true title overflow OK (LTR)', (WidgetTester tester) async { // The app bar's title should be constrained to fit within the available space // between the leading and actions widgets. When it's also centered it may // also be start or end justified if it doesn't fit in the overall center. @@ -414,7 +415,7 @@ void main() { expect(tester.getSize(title).width, equals(620.0)); }); - testWidgets('AppBar centerTitle:true title overflow OK (RTL)', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar centerTitle:true title overflow OK (RTL)', (WidgetTester tester) async { // The app bar's title should be constrained to fit within the available space // between the leading and actions widgets. When it's also centered it may // also be start or end justified if it doesn't fit in the overall center. @@ -469,7 +470,7 @@ void main() { expect(tester.getSize(title).width, equals(620.0)); }); - testWidgets('AppBar with no Scaffold', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar with no Scaffold', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: SizedBox( @@ -489,7 +490,7 @@ void main() { expect(find.text('A2'), findsOneWidget); }); - testWidgets('AppBar render at zero size', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar render at zero size', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: Center( @@ -508,7 +509,7 @@ void main() { expect(tester.getSize(title).isEmpty, isTrue); }); - testWidgets('AppBar actions are vertically centered', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar actions are vertically centered', (WidgetTester tester) async { final UniqueKey appBarKey = UniqueKey(); final UniqueKey leadingKey = UniqueKey(); final UniqueKey titleKey = UniqueKey(); @@ -540,7 +541,7 @@ void main() { expect(yCenter(appBarKey), equals(yCenter(action1Key))); }); - testWidgets('AppBar drawer icon has default size', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar drawer icon has default size', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: Scaffold( @@ -558,7 +559,7 @@ void main() { ); }); - testWidgets('Material2 - AppBar drawer icon has default color', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material2 - AppBar drawer icon has default color', (WidgetTester tester) async { final ThemeData themeData = ThemeData.from( colorScheme: const ColorScheme.light(), useMaterial3: false, @@ -578,7 +579,7 @@ void main() { expect(_iconStyle(tester, Icons.menu)?.color, themeData.colorScheme.onPrimary); }); - testWidgets('Material3 - AppBar drawer icon has default color', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBar drawer icon has default color', (WidgetTester tester) async { final ThemeData themeData = ThemeData.from( colorScheme: const ColorScheme.light(), useMaterial3: true, @@ -598,7 +599,7 @@ void main() { expect(_iconStyle(tester, Icons.menu)?.color, themeData.colorScheme.onSurfaceVariant); }); - testWidgets('AppBar drawer icon is sized by iconTheme', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar drawer icon is sized by iconTheme', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: Scaffold( @@ -616,7 +617,7 @@ void main() { ); }); - testWidgets('AppBar drawer icon is colored by iconTheme', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar drawer icon is colored by iconTheme', (WidgetTester tester) async { final ThemeData themeData = ThemeData.from(colorScheme: const ColorScheme.light()); const Color color = Color(0xFF2196F3); @@ -636,7 +637,7 @@ void main() { expect(_iconStyle(tester, Icons.menu)?.color, color); }); - testWidgets('AppBar endDrawer icon has default size', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar endDrawer icon has default size', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: Scaffold( @@ -655,7 +656,7 @@ void main() { ); }); - testWidgets('Material2 - AppBar endDrawer icon has default color', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material2 - AppBar endDrawer icon has default color', (WidgetTester tester) async { final ThemeData themeData = ThemeData.from( colorScheme: const ColorScheme.light(), useMaterial3: false, @@ -675,7 +676,7 @@ void main() { expect(_iconStyle(tester, Icons.menu)?.color, themeData.colorScheme.onPrimary); }); - testWidgets('Material3 - AppBar endDrawer icon has default color', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBar endDrawer icon has default color', (WidgetTester tester) async { final ThemeData themeData = ThemeData.from( colorScheme: const ColorScheme.light(), useMaterial3: true, @@ -695,7 +696,7 @@ void main() { expect(_iconStyle(tester, Icons.menu)?.color, themeData.colorScheme.onSurfaceVariant); }); - testWidgets('AppBar endDrawer icon is sized by iconTheme', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar endDrawer icon is sized by iconTheme', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: Scaffold( @@ -713,7 +714,7 @@ void main() { ); }); - testWidgets('AppBar endDrawer icon is colored by iconTheme', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar endDrawer icon is colored by iconTheme', (WidgetTester tester) async { final ThemeData themeData = ThemeData.from(colorScheme: const ColorScheme.light()); const Color color = Color(0xFF2196F3); @@ -733,7 +734,7 @@ void main() { expect(_iconStyle(tester, Icons.menu)?.color, color); }); - testWidgets('Material2 - leading widget extends to edge and is square', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material2 - leading widget extends to edge and is square', (WidgetTester tester) async { final ThemeData themeData = ThemeData( platform: TargetPlatform.android, useMaterial3: false, @@ -791,7 +792,7 @@ void main() { expect(tester.getSize(leading), const Size(56.0, 56.0)); }); - testWidgets('Material3 - leading widget extends to edge and is square', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - leading widget extends to edge and is square', (WidgetTester tester) async { final ThemeData themeData = ThemeData( platform: TargetPlatform.android, useMaterial3: true, @@ -849,7 +850,7 @@ void main() { expect(tester.getSize(leading), const Size(56.0, 56.0)); }); - testWidgets('Material2 - Action is 4dp from edge and 48dp min', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material2 - Action is 4dp from edge and 48dp min', (WidgetTester tester) async { final ThemeData theme = ThemeData( platform: TargetPlatform.android, useMaterial3: false, @@ -889,7 +890,7 @@ void main() { expect(tester.getSize(shareButton), const Size(48.0, 56.0)); }); - testWidgets('Material3 - Action is 4dp from edge and 48dp min', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - Action is 4dp from edge and 48dp min', (WidgetTester tester) async { final ThemeData theme = ThemeData( platform: TargetPlatform.android, useMaterial3: true, @@ -929,7 +930,7 @@ void main() { expect(tester.getSize(shareButton), const Size(48.0, 48.0)); }); - testWidgets('SliverAppBar default configuration', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar default configuration', (WidgetTester tester) async { await tester.pumpWidget(buildSliverAppBarApp()); final ScrollController controller = primaryScrollController(tester); @@ -961,7 +962,7 @@ void main() { expect(tabBarHeight(tester), initialTabBarHeight); }); - testWidgets('SliverAppBar expandedHeight, pinned', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar expandedHeight, pinned', (WidgetTester tester) async { await tester.pumpWidget(buildSliverAppBarApp( pinned: true, expandedHeight: 128.0, @@ -992,7 +993,7 @@ void main() { expect(tabBarHeight(tester), initialTabBarHeight); }); - testWidgets('SliverAppBar expandedHeight, pinned and floating', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar expandedHeight, pinned and floating', (WidgetTester tester) async { await tester.pumpWidget(buildSliverAppBarApp( floating: true, pinned: true, @@ -1024,7 +1025,7 @@ void main() { expect(tabBarHeight(tester), initialTabBarHeight); }); - testWidgets('SliverAppBar expandedHeight, floating with snap:true', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar expandedHeight, floating with snap:true', (WidgetTester tester) async { await tester.pumpWidget(buildSliverAppBarApp( floating: true, snap: true, @@ -1104,7 +1105,7 @@ void main() { expect(appBarBottom(tester), lessThanOrEqualTo(0.0)); }); - testWidgets('SliverAppBar expandedHeight, floating and pinned with snap:true', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar expandedHeight, floating and pinned with snap:true', (WidgetTester tester) async { await tester.pumpWidget(buildSliverAppBarApp( floating: true, pinned: true, @@ -1190,7 +1191,7 @@ void main() { expect(appBarBottom(tester), kTextTabBarHeight); }); - testWidgets('SliverAppBar expandedHeight, collapsedHeight', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar expandedHeight, collapsedHeight', (WidgetTester tester) async { const double expandedAppBarHeight = 400.0; const double collapsedAppBarHeight = 200.0; @@ -1228,7 +1229,7 @@ void main() { expect(tabBarHeight(tester), initialTabBarHeight); }); - testWidgets('Material3 - SliverAppBar.medium defaults', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - SliverAppBar.medium defaults', (WidgetTester tester) async { final ThemeData theme = ThemeData(useMaterial3: true); const double collapsedAppBarHeight = 64; const double expandedAppBarHeight = 112; @@ -1317,7 +1318,7 @@ void main() { expect(tester.getSize(expandedTitleClip).height, expandedAppBarHeight - collapsedAppBarHeight); }); - testWidgets('Material3 - SliverAppBar.large defaults', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - SliverAppBar.large defaults', (WidgetTester tester) async { final ThemeData theme = ThemeData(useMaterial3: true); const double collapsedAppBarHeight = 64; const double expandedAppBarHeight = 152; @@ -1410,7 +1411,7 @@ void main() { expect(tester.getSize(expandedTitleClip).height, expandedAppBarHeight - collapsedAppBarHeight); }); - testWidgets('Material2 - AppBar uses the specified elevation or defaults to 4.0', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material2 - AppBar uses the specified elevation or defaults to 4.0', (WidgetTester tester) async { Widget buildAppBar([double? elevation]) { return MaterialApp( theme: ThemeData(useMaterial3: false), @@ -1434,7 +1435,7 @@ void main() { expect(getMaterial().elevation, 8.0); }); - testWidgets('Material3 - AppBar uses the specified elevation or defaults to 0', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBar uses the specified elevation or defaults to 0', (WidgetTester tester) async { Widget buildAppBar([double? elevation]) { return MaterialApp( theme: ThemeData(useMaterial3: true), @@ -1458,7 +1459,7 @@ void main() { expect(getMaterial().elevation, 8.0); }); - testWidgets('scrolledUnderElevation', (WidgetTester tester) async { + testWidgetsWithLeakTracking('scrolledUnderElevation', (WidgetTester tester) async { Widget buildAppBar({double? elevation, double? scrolledUnderElevation}) { return MaterialApp( home: Scaffold( @@ -1491,7 +1492,7 @@ void main() { expect(getMaterial().elevation, 10); }); - testWidgets('Material3 - scrolledUnderElevation with nested scroll view', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - scrolledUnderElevation with nested scroll view', (WidgetTester tester) async { Widget buildAppBar({double? scrolledUnderElevation}) { return MaterialApp( theme: ThemeData(useMaterial3: true), @@ -1560,7 +1561,7 @@ void main() { ); } - testWidgets('Respects forceElevated parameter', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Respects forceElevated parameter', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/59158. AppBar getAppBar() => tester.widget(find.byType(AppBar)); Material getMaterial() => tester.widget(find.byType(Material)); @@ -1583,7 +1584,7 @@ void main() { expect(getMaterial().elevation, 8.0); }); - testWidgets('Uses elevation of AppBarTheme by default', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Uses elevation of AppBarTheme by default', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/73525. Material getMaterial() => tester.widget(find.byType(Material)); @@ -1646,7 +1647,7 @@ void main() { ); } - testWidgets( + testWidgetsWithLeakTracking( 'forceMaterialTransparency == true allows gestures beneath the app bar', (WidgetTester tester) async { bool buttonWasPressed = false; final Widget widget = buildWidget( @@ -1664,7 +1665,7 @@ void main() { expect(buttonWasPressed, isTrue); }); - testWidgets( + testWidgetsWithLeakTracking( 'forceMaterialTransparency == false does not allow gestures beneath the app bar', (WidgetTester tester) async { // Set this, and tester.tap(warnIfMissed:false), to suppress // errors/warning that the button is not hittable (which is expected). @@ -1687,7 +1688,7 @@ void main() { }); }); - testWidgets('AppBar dimensions, with and without bottom, primary', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar dimensions, with and without bottom, primary', (WidgetTester tester) async { const MediaQueryData topPadding100 = MediaQueryData(padding: EdgeInsets.only(top: 100.0)); await tester.pumpWidget( @@ -1812,7 +1813,7 @@ void main() { expect(tester.getTopLeft(find.text('title')).dy, lessThan(100.0)); }); - testWidgets('AppBar in body excludes bottom SafeArea padding', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar in body excludes bottom SafeArea padding', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/26163 await tester.pumpWidget( Localizations( @@ -1842,7 +1843,7 @@ void main() { expect(appBarHeight(tester), kToolbarHeight + 100.0); }); - testWidgets('AppBar.title sees the correct padding from MediaQuery', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar.title sees the correct padding from MediaQuery', (WidgetTester tester) async { bool titleBuilt = false; await tester.pumpWidget( Localizations( @@ -1872,7 +1873,7 @@ void main() { expect(titleBuilt, isTrue); }); - testWidgets('AppBar updates when you add a drawer', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar updates when you add a drawer', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: Scaffold( @@ -1892,7 +1893,7 @@ void main() { expect(find.byIcon(Icons.menu), findsOneWidget); }); - testWidgets('AppBar does not draw menu for drawer if automaticallyImplyLeading is false', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar does not draw menu for drawer if automaticallyImplyLeading is false', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: Scaffold( @@ -1906,7 +1907,7 @@ void main() { expect(find.byIcon(Icons.menu), findsNothing); }); - testWidgets('AppBar does not update the leading if a route is popped case 1', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar does not update the leading if a route is popped case 1', (WidgetTester tester) async { final Page page1 = MaterialPage( key: const ValueKey('1'), child: Scaffold( @@ -1944,7 +1945,7 @@ void main() { expect(find.byType(BackButton), findsNothing); }); - testWidgets('AppBar does not update the leading if a route is popped case 2', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar does not update the leading if a route is popped case 2', (WidgetTester tester) async { final Page page1 = MaterialPage( key: const ValueKey('1'), child: Scaffold( @@ -1997,7 +1998,7 @@ void main() { ); }); - testWidgets('Material2 - AppBar ink splash draw on the correct canvas', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material2 - AppBar ink splash draw on the correct canvas', (WidgetTester tester) async { // This is a regression test for https://github.com/flutter/flutter/issues/58665 final Key key = UniqueKey(); await tester.pumpWidget( @@ -2044,7 +2045,7 @@ void main() { expect(painter, paints..save()..translate()..save()..translate()..circle(x: 24.0, y: 28.0)); }); - testWidgets('Material3 - AppBar ink splash draw on the correct canvas', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBar ink splash draw on the correct canvas', (WidgetTester tester) async { // This is a regression test for https://github.com/flutter/flutter/issues/58665 final Key key = UniqueKey(); await tester.pumpWidget( @@ -2091,7 +2092,7 @@ void main() { expect(painter, paints..save()..translate()..save()..translate()..circle(x: 20.0, y: 20.0)); }); - testWidgets('AppBar handles loose children 0', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar handles loose children 0', (WidgetTester tester) async { final GlobalKey key = GlobalKey(); await tester.pumpWidget( MaterialApp( @@ -2112,7 +2113,7 @@ void main() { expect(tester.renderObject(find.byKey(key)).size, const Size(56.0, 56.0)); }); - testWidgets('AppBar handles loose children 1', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar handles loose children 1', (WidgetTester tester) async { final GlobalKey key = GlobalKey(); await tester.pumpWidget( MaterialApp( @@ -2142,7 +2143,7 @@ void main() { expect(tester.renderObject(find.byKey(key)).size, const Size(56.0, 56.0)); }); - testWidgets('AppBar handles loose children 2', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar handles loose children 2', (WidgetTester tester) async { final GlobalKey key = GlobalKey(); await tester.pumpWidget( MaterialApp( @@ -2182,7 +2183,7 @@ void main() { expect(tester.renderObject(find.byKey(key)).size, const Size(56.0, 56.0)); }); - testWidgets('AppBar handles loose children 3', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar handles loose children 3', (WidgetTester tester) async { final GlobalKey key = GlobalKey(); await tester.pumpWidget( MaterialApp( @@ -2213,7 +2214,7 @@ void main() { expect(tester.renderObject(find.byKey(key)).size, const Size(56.0, 56.0)); }); - testWidgets('AppBar positioning of leading and trailing widgets with top padding', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar positioning of leading and trailing widgets with top padding', (WidgetTester tester) async { const MediaQueryData topPadding100 = MediaQueryData(padding: EdgeInsets.only(top: 100)); final Key leadingKey = UniqueKey(); final Key titleKey = UniqueKey(); @@ -2256,7 +2257,7 @@ void main() { expect(tester.getTopLeft(find.byKey(titleKey)), const Offset(10 + NavigationToolbar.kMiddleSpacing, 72)); }); - testWidgets('SliverAppBar positioning of leading and trailing widgets with top padding', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar positioning of leading and trailing widgets with top padding', (WidgetTester tester) async { const MediaQueryData topPadding100 = MediaQueryData(padding: EdgeInsets.only(top: 100.0)); final Key leadingKey = UniqueKey(); final Key titleKey = UniqueKey(); @@ -2293,7 +2294,7 @@ void main() { expect(tester.getTopLeft(find.byKey(trailingKey)), const Offset(0.0, 100.0)); }); - testWidgets('SliverAppBar positioning of leading and trailing widgets with bottom padding', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar positioning of leading and trailing widgets with bottom padding', (WidgetTester tester) async { const MediaQueryData topPadding100 = MediaQueryData(padding: EdgeInsets.only(top: 100.0, bottom: 50.0)); final Key leadingKey = UniqueKey(); final Key titleKey = UniqueKey(); @@ -2329,7 +2330,7 @@ void main() { expect(tester.getRect(find.byKey(trailingKey)), const Rect.fromLTRB(0.0, 100.0, 400.0, 100.0 + 56.0)); }); - testWidgets('SliverAppBar provides correct semantics in LTR', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar provides correct semantics in LTR', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( @@ -2410,7 +2411,7 @@ void main() { semantics.dispose(); }); - testWidgets('SliverAppBar provides correct semantics in RTL', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar provides correct semantics in RTL', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( @@ -2502,7 +2503,7 @@ void main() { semantics.dispose(); }); - testWidgets('AppBar excludes header semantics correctly', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar excludes header semantics correctly', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( @@ -2558,7 +2559,7 @@ void main() { semantics.dispose(); }); - testWidgets('SliverAppBar excludes header semantics correctly', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar excludes header semantics correctly', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( @@ -2627,7 +2628,7 @@ void main() { semantics.dispose(); }); - testWidgets('SliverAppBar with flexible space has correct semantics order', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar with flexible space has correct semantics order', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/64922. final SemanticsTester semantics = SemanticsTester(tester); @@ -2704,7 +2705,7 @@ void main() { semantics.dispose(); }); - testWidgets('Material2 - AppBar draws a light system bar for a dark background', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material2 - AppBar draws a light system bar for a dark background', (WidgetTester tester) async { final ThemeData darkTheme = ThemeData.dark(useMaterial3: false); await tester.pumpWidget(MaterialApp( theme: darkTheme, @@ -2722,7 +2723,7 @@ void main() { )); }); - testWidgets('Material3 - AppBar draws a light system bar for a dark background', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBar draws a light system bar for a dark background', (WidgetTester tester) async { final ThemeData darkTheme = ThemeData.dark(useMaterial3: true); await tester.pumpWidget(MaterialApp( theme: darkTheme, @@ -2741,7 +2742,7 @@ void main() { )); }); - testWidgets('Material2 - AppBar draws a dark system bar for a light background', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material2 - AppBar draws a dark system bar for a light background', (WidgetTester tester) async { final ThemeData lightTheme = ThemeData(primarySwatch: Colors.lightBlue, useMaterial3: false); await tester.pumpWidget( MaterialApp( @@ -2761,7 +2762,7 @@ void main() { )); }); - testWidgets('Material3 - AppBar draws a dark system bar for a light background', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBar draws a dark system bar for a light background', (WidgetTester tester) async { final ThemeData lightTheme = ThemeData(useMaterial3: true); await tester.pumpWidget( MaterialApp( @@ -2782,7 +2783,7 @@ void main() { )); }); - testWidgets('Material2 - Default system bar brightness based on AppBar background color brightness.', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material2 - Default system bar brightness based on AppBar background color brightness.', (WidgetTester tester) async { Widget buildAppBar(ThemeData theme) { return MaterialApp( theme: theme, @@ -2833,7 +2834,7 @@ void main() { } }); - testWidgets('Material3 - Default system bar brightness based on AppBar background color brightness.', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - Default system bar brightness based on AppBar background color brightness.', (WidgetTester tester) async { Widget buildAppBar(ThemeData theme) { return MaterialApp( theme: theme, @@ -2886,7 +2887,7 @@ void main() { } }); - testWidgets('Material2 - Default status bar color', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material2 - Default status bar color', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( key: GlobalKey(), @@ -2905,7 +2906,7 @@ void main() { expect(SystemChrome.latestStyle!.statusBarColor, null); }); - testWidgets('Material3 - Default status bar color', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - Default status bar color', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( key: GlobalKey(), @@ -2924,7 +2925,7 @@ void main() { expect(SystemChrome.latestStyle!.statusBarColor, Colors.transparent); }); - testWidgets('AppBar systemOverlayStyle is use to style status bar and navigation bar', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar systemOverlayStyle is use to style status bar and navigation bar', (WidgetTester tester) async { final SystemUiOverlayStyle systemOverlayStyle = SystemUiOverlayStyle.light.copyWith( statusBarColor: Colors.red, systemNavigationBarColor: Colors.green, @@ -2944,7 +2945,7 @@ void main() { expect(SystemChrome.latestStyle!.systemNavigationBarColor, Colors.green); }); - testWidgets('Changing SliverAppBar snap from true to false', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Changing SliverAppBar snap from true to false', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/17598 const double appBarHeight = 256.0; bool snap = true; @@ -3005,7 +3006,7 @@ void main() { await tester.pump(); }); - testWidgets('AppBar shape default', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar shape default', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: AppBar( @@ -3025,7 +3026,7 @@ void main() { expect(getMaterialWidget(materialFinder).shape, null); }); - testWidgets('AppBar with shape', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar with shape', (WidgetTester tester) async { const RoundedRectangleBorder roundedRectangleBorder = RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(15.0)), ); @@ -3049,7 +3050,7 @@ void main() { expect(getMaterialWidget(materialFinder).shape, roundedRectangleBorder); }); - testWidgets('SliverAppBar shape default', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar shape default', (WidgetTester tester) async { await tester.pumpWidget( const MaterialApp( home: CustomScrollView( @@ -3073,7 +3074,7 @@ void main() { expect(getMaterialWidget(materialFinder).shape, null); }); - testWidgets('SliverAppBar with shape', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar with shape', (WidgetTester tester) async { const RoundedRectangleBorder roundedRectangleBorder = RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(15.0)), ); @@ -3101,7 +3102,7 @@ void main() { expect(getMaterialWidget(materialFinder).shape, roundedRectangleBorder); }); - testWidgets('AppBars title has upper limit on text scaling, textScaleFactor = 1, 1.34, 2', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBars title has upper limit on text scaling, textScaleFactor = 1, 1.34, 2', (WidgetTester tester) async { late double textScaleFactor; Widget buildFrame() { @@ -3139,7 +3140,7 @@ void main() { expect(tester.getRect(appBarTitle).height, 24); }); - testWidgets('AppBars with jumbo titles, textScaleFactor = 3, 3.5, 4', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBars with jumbo titles, textScaleFactor = 3, 3.5, 4', (WidgetTester tester) async { double textScaleFactor = 1.0; TextDirection textDirection = TextDirection.ltr; bool centerTitle = false; @@ -3209,7 +3210,7 @@ void main() { expect(tester.getCenter(appBarTitle).dy, tester.getCenter(toolbar).dy); }); - testWidgets('SliverAppBar configures the delegate properly', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar configures the delegate properly', (WidgetTester tester) async { Future buildAndVerifyDelegate({ required bool pinned, required bool floating, required bool snap }) async { await tester.pumpWidget( MaterialApp( @@ -3245,7 +3246,7 @@ void main() { await buildAndVerifyDelegate(pinned: true, floating: true, snap: true); }); - testWidgets('AppBar respects toolbarHeight', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar respects toolbarHeight', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: Scaffold( @@ -3261,7 +3262,7 @@ void main() { expect(appBarHeight(tester), 48); }); - testWidgets('SliverAppBar default collapsedHeight with respect to toolbarHeight', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar default collapsedHeight with respect to toolbarHeight', (WidgetTester tester) async { const double toolbarHeight = 100.0; await tester.pumpWidget(buildSliverAppBarApp( @@ -3280,7 +3281,7 @@ void main() { expect(appBarHeight(tester), toolbarHeight + initialTabBarHeight); }); - testWidgets('SliverAppBar collapsedHeight with toolbarHeight', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar collapsedHeight with toolbarHeight', (WidgetTester tester) async { const double toolbarHeight = 100.0; const double collapsedHeight = 150.0; @@ -3299,7 +3300,7 @@ void main() { expect(appBarHeight(tester), collapsedHeight + initialTabBarHeight); }); - testWidgets('SliverAppBar collapsedHeight', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar collapsedHeight', (WidgetTester tester) async { const double collapsedHeight = 56.0; await tester.pumpWidget(buildSliverAppBarApp( @@ -3316,7 +3317,7 @@ void main() { expect(appBarHeight(tester), collapsedHeight + initialTabBarHeight); }); - testWidgets('AppBar respects leadingWidth', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar respects leadingWidth', (WidgetTester tester) async { const Key key = Key('leading'); await tester.pumpWidget(MaterialApp( home: Scaffold( @@ -3332,7 +3333,7 @@ void main() { expect(tester.getRect(find.byKey(key)), const Rect.fromLTRB(0, 0, 100, 56)); }); - testWidgets('SliverAppBar respects leadingWidth', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar respects leadingWidth', (WidgetTester tester) async { const Key key = Key('leading'); await tester.pumpWidget(const MaterialApp( home: CustomScrollView( @@ -3367,7 +3368,7 @@ void main() { expect(getAppBarWidget(appBarFinder).leading, null); }); - testWidgets('AppBar.titleSpacing defaults to NavigationToolbar.kMiddleSpacing', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar.titleSpacing defaults to NavigationToolbar.kMiddleSpacing', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp( home: Scaffold( appBar: AppBar( @@ -3380,14 +3381,14 @@ void main() { expect(navToolBar.middleSpacing, NavigationToolbar.kMiddleSpacing); }); - testWidgets('SliverAppBar.titleSpacing defaults to NavigationToolbar.kMiddleSpacing', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar.titleSpacing defaults to NavigationToolbar.kMiddleSpacing', (WidgetTester tester) async { await tester.pumpWidget(buildSliverAppBarApp()); final NavigationToolbar navToolBar = tester.widget(find.byType(NavigationToolbar)); expect(navToolBar.middleSpacing, NavigationToolbar.kMiddleSpacing); }); - testWidgets('AppBar foregroundColor and backgroundColor', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar foregroundColor and backgroundColor', (WidgetTester tester) async { const Color foregroundColor = Color(0xff00ff00); const Color backgroundColor = Color(0xff00ffff); final Key leadingIconKey = UniqueKey(); @@ -3438,7 +3439,7 @@ void main() { expect(actionIconColor(), foregroundColor); }); - testWidgets('Leading, title, and actions show correct default colors', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Leading, title, and actions show correct default colors', (WidgetTester tester) async { final ThemeData themeData = ThemeData.from( colorScheme: const ColorScheme.light( onPrimary: Colors.blue, @@ -3476,7 +3477,7 @@ void main() { // Regression test for https://github.com/flutter/flutter/issues/107305 group('Material3 - Icons are colored correctly by IconTheme and ActionIconTheme', () { - testWidgets('Material3 - Icons and IconButtons are colored by IconTheme', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - Icons and IconButtons are colored by IconTheme', (WidgetTester tester) async { const Color iconColor = Color(0xff00ff00); final Key leadingIconKey = UniqueKey(); final Key actionIconKey = UniqueKey(); @@ -3508,7 +3509,7 @@ void main() { expect(actionIconButtonColor(), iconColor); }); - testWidgets('Material3 - Action icons and IconButtons are colored by ActionIconTheme', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - Action icons and IconButtons are colored by ActionIconTheme', (WidgetTester tester) async { final ThemeData themeData = ThemeData.from( colorScheme: const ColorScheme.light(), useMaterial3: true, @@ -3544,7 +3545,7 @@ void main() { expect(actionIconButtonColor(), actionsIconColor); }); - testWidgets('Material3 - The actionIconTheme property overrides iconTheme', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - The actionIconTheme property overrides iconTheme', (WidgetTester tester) async { final ThemeData themeData = ThemeData.from( colorScheme: const ColorScheme.light(), useMaterial3: true, @@ -3582,7 +3583,7 @@ void main() { expect(actionIconButtonColor(), actionsIconColor); }); - testWidgets('Material3 - AppBar.iconTheme should override any IconButtonTheme present in the theme', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBar.iconTheme should override any IconButtonTheme present in the theme', (WidgetTester tester) async { final ThemeData themeData = ThemeData( iconButtonTheme: IconButtonThemeData( style: IconButton.styleFrom( @@ -3621,7 +3622,7 @@ void main() { expect(actionIconButtonSize(), 30.0); }); - testWidgets('Material3 - AppBar.iconTheme should override any IconButtonTheme present in the theme for widgets containing an iconButton', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBar.iconTheme should override any IconButtonTheme present in the theme for widgets containing an iconButton', (WidgetTester tester) async { final ThemeData themeData = ThemeData( iconButtonTheme: IconButtonThemeData( style: IconButton.styleFrom( @@ -3654,7 +3655,7 @@ void main() { }); - testWidgets('Material3 - AppBar.actionsIconTheme should override any IconButtonTheme present in the theme', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBar.actionsIconTheme should override any IconButtonTheme present in the theme', (WidgetTester tester) async { final ThemeData themeData = ThemeData( iconButtonTheme: IconButtonThemeData( style: IconButton.styleFrom( @@ -3694,7 +3695,7 @@ void main() { expect(actionIconButtonSize(), 30.0); }); - testWidgets('Material3 - AppBar.actionsIconTheme should override any IconButtonTheme present in the theme for widgets containing an iconButton', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBar.actionsIconTheme should override any IconButtonTheme present in the theme for widgets containing an iconButton', (WidgetTester tester) async { final ThemeData themeData = ThemeData( iconButtonTheme: IconButtonThemeData( style: IconButton.styleFrom( @@ -3728,7 +3729,7 @@ void main() { expect(actionIconButtonSize(), 30.0); }); - testWidgets('Material3 - The foregroundColor property of the AppBar overrides any IconButtonTheme present in the theme', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - The foregroundColor property of the AppBar overrides any IconButtonTheme present in the theme', (WidgetTester tester) async { final ThemeData themeData = ThemeData( iconButtonTheme: IconButtonThemeData( style: IconButton.styleFrom( @@ -3762,7 +3763,7 @@ void main() { }); // This is a regression test for https://github.com/flutter/flutter/issues/130485. - testWidgets('Material3 - AppBar.iconTheme is correctly applied in dark mode', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBar.iconTheme is correctly applied in dark mode', (WidgetTester tester) async { final ThemeData themeData = ThemeData( colorScheme: const ColorScheme.dark().copyWith(onSurfaceVariant: Colors.red), useMaterial3: true, @@ -3790,7 +3791,7 @@ void main() { }); // This is a regression test for https://github.com/flutter/flutter/issues/130485. - testWidgets('Material3 - AppBar.foregroundColor is correctly applied in dark mode', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBar.foregroundColor is correctly applied in dark mode', (WidgetTester tester) async { final ThemeData themeData = ThemeData( colorScheme: const ColorScheme.dark().copyWith(onSurfaceVariant: Colors.red), useMaterial3: true, @@ -3818,7 +3819,7 @@ void main() { }); // This is a regression test for https://github.com/flutter/flutter/issues/130485. - testWidgets('Material3 - AppBar.iconTheme is correctly applied in light mode', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBar.iconTheme is correctly applied in light mode', (WidgetTester tester) async { final ThemeData themeData = ThemeData( colorScheme: const ColorScheme.light().copyWith(onSurfaceVariant: Colors.red), useMaterial3: true, @@ -3846,7 +3847,7 @@ void main() { }); // This is a regression test for https://github.com/flutter/flutter/issues/130485. - testWidgets('Material3 - AppBar.foregroundColor is correctly applied in light mode', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBar.foregroundColor is correctly applied in light mode', (WidgetTester tester) async { final ThemeData themeData = ThemeData( colorScheme: const ColorScheme.light().copyWith(onSurfaceVariant: Colors.red), useMaterial3: true, @@ -3925,7 +3926,7 @@ void main() { ); } - testWidgets('backgroundColor', (WidgetTester tester) async { + testWidgetsWithLeakTracking('backgroundColor', (WidgetTester tester) async { await tester.pumpWidget( buildSliverApp(contentHeight: 1200.0) ); @@ -3950,7 +3951,7 @@ void main() { expect(tester.getSize(findAppBarMaterial()).height, expandedHeight); }); - testWidgets('backgroundColor with FlexibleSpace', (WidgetTester tester) async { + testWidgetsWithLeakTracking('backgroundColor with FlexibleSpace', (WidgetTester tester) async { await tester.pumpWidget( buildSliverApp(contentHeight: 1200.0, includeFlexibleSpace: true) ); @@ -3975,7 +3976,7 @@ void main() { expect(tester.getSize(findAppBarMaterial()).height, expandedHeight); }); - testWidgets('backgroundColor - reverse', (WidgetTester tester) async { + testWidgetsWithLeakTracking('backgroundColor - reverse', (WidgetTester tester) async { await tester.pumpWidget( buildSliverApp(contentHeight: 1200.0, reverse: true) ); @@ -4000,7 +4001,7 @@ void main() { expect(tester.getSize(findAppBarMaterial()).height, expandedHeight); }); - testWidgets('backgroundColor with FlexibleSpace - reverse', (WidgetTester tester) async { + testWidgetsWithLeakTracking('backgroundColor with FlexibleSpace - reverse', (WidgetTester tester) async { await tester.pumpWidget( buildSliverApp( contentHeight: 1200.0, @@ -4029,7 +4030,7 @@ void main() { expect(tester.getSize(findAppBarMaterial()).height, expandedHeight); }); - testWidgets('backgroundColor - not triggered in reverse for short content', (WidgetTester tester) async { + testWidgetsWithLeakTracking('backgroundColor - not triggered in reverse for short content', (WidgetTester tester) async { await tester.pumpWidget( buildSliverApp(contentHeight: 200, reverse: true) ); @@ -4048,7 +4049,7 @@ void main() { expect(tester.getSize(findAppBarMaterial()).height, expandedHeight); }); - testWidgets('backgroundColor with FlexibleSpace - not triggered in reverse for short content', (WidgetTester tester) async { + testWidgetsWithLeakTracking('backgroundColor with FlexibleSpace - not triggered in reverse for short content', (WidgetTester tester) async { await tester.pumpWidget( buildSliverApp( contentHeight: 200, @@ -4102,7 +4103,7 @@ void main() { ); } - testWidgets('backgroundColor for horizontal scrolling', (WidgetTester tester) async { + testWidgetsWithLeakTracking('backgroundColor for horizontal scrolling', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: Scaffold( @@ -4160,7 +4161,7 @@ void main() { expect(tester.getSize(findAppBarMaterial()).height, kToolbarHeight); }); - testWidgets('backgroundColor', (WidgetTester tester) async { + testWidgetsWithLeakTracking('backgroundColor', (WidgetTester tester) async { await tester.pumpWidget( buildAppBar(contentHeight: 1200.0) ); @@ -4185,7 +4186,7 @@ void main() { expect(tester.getSize(findAppBarMaterial()).height, kToolbarHeight); }); - testWidgets('backgroundColor with FlexibleSpace', (WidgetTester tester) async { + testWidgetsWithLeakTracking('backgroundColor with FlexibleSpace', (WidgetTester tester) async { await tester.pumpWidget( buildAppBar(contentHeight: 1200.0, includeFlexibleSpace: true) ); @@ -4210,7 +4211,7 @@ void main() { expect(tester.getSize(findAppBarMaterial()).height, kToolbarHeight); }); - testWidgets('backgroundColor - reverse', (WidgetTester tester) async { + testWidgetsWithLeakTracking('backgroundColor - reverse', (WidgetTester tester) async { await tester.pumpWidget( buildAppBar(contentHeight: 1200.0, reverse: true) ); @@ -4238,7 +4239,7 @@ void main() { expect(tester.getSize(findAppBarMaterial()).height, kToolbarHeight); }); - testWidgets('backgroundColor with FlexibleSpace - reverse', (WidgetTester tester) async { + testWidgetsWithLeakTracking('backgroundColor with FlexibleSpace - reverse', (WidgetTester tester) async { await tester.pumpWidget( buildAppBar( contentHeight: 1200.0, @@ -4270,7 +4271,7 @@ void main() { expect(tester.getSize(findAppBarMaterial()).height, kToolbarHeight); }); - testWidgets('_handleScrollNotification safely calls setState()', (WidgetTester tester) async { + testWidgetsWithLeakTracking('_handleScrollNotification safely calls setState()', (WidgetTester tester) async { // Regression test for failures found in Google internal issue b/185192049. final ScrollController controller = ScrollController(initialScrollOffset: 400); await tester.pumpWidget( @@ -4296,7 +4297,7 @@ void main() { expect(tester.takeException(), isNull); }); - testWidgets('does not trigger on horizontal scroll', (WidgetTester tester) async { + testWidgetsWithLeakTracking('does not trigger on horizontal scroll', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: Scaffold( @@ -4336,7 +4337,7 @@ void main() { expect(getAppBarBackgroundColor(tester), defaultColor); }); - testWidgets('backgroundColor - not triggered in reverse for short content', (WidgetTester tester) async { + testWidgetsWithLeakTracking('backgroundColor - not triggered in reverse for short content', (WidgetTester tester) async { await tester.pumpWidget( buildAppBar( contentHeight: 200.0, @@ -4359,7 +4360,7 @@ void main() { expect(tester.getSize(findAppBarMaterial()).height, kToolbarHeight); }); - testWidgets('backgroundColor with FlexibleSpace - not triggered in reverse for short content', (WidgetTester tester) async { + testWidgetsWithLeakTracking('backgroundColor with FlexibleSpace - not triggered in reverse for short content', (WidgetTester tester) async { await tester.pumpWidget( buildAppBar( contentHeight: 200.0, @@ -4386,7 +4387,7 @@ void main() { }); // Regression test for https://github.com/flutter/flutter/issues/80256 - testWidgets('The second page should have a back button even it has a end drawer', (WidgetTester tester) async { + testWidgetsWithLeakTracking('The second page should have a back button even it has a end drawer', (WidgetTester tester) async { final Page page1 = MaterialPage( key: const ValueKey('1'), child: Scaffold( @@ -4423,7 +4424,7 @@ void main() { ); }); - testWidgets('Only local entries that imply app bar dismissal will introduce an back button', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Only local entries that imply app bar dismissal will introduce an back button', (WidgetTester tester) async { final GlobalKey key = GlobalKey(); await tester.pumpWidget( MaterialApp( @@ -4450,7 +4451,7 @@ void main() { expect(find.byType(BackButton), findsOneWidget); }); - testWidgets('AppBar.preferredHeightFor', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar.preferredHeightFor', (WidgetTester tester) async { late double preferredHeight; late Size preferredSize; @@ -4503,7 +4504,7 @@ void main() { expect(preferredSize.height, 64); }); - testWidgets('AppBar title with actions should have the same position regardless of centerTitle', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar title with actions should have the same position regardless of centerTitle', (WidgetTester tester) async { final Key titleKey = UniqueKey(); bool centerTitle = false; @@ -4533,7 +4534,7 @@ void main() { expect(tester.getTopLeft(title).dx, 16.0); }); - testWidgets('AppBar leading widget can take up arbitrary space', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar leading widget can take up arbitrary space', (WidgetTester tester) async { final Key leadingKey = UniqueKey(); final Key titleKey = UniqueKey(); late double leadingWidth; @@ -4563,7 +4564,7 @@ void main() { expect(tester.getSize(find.byKey(leadingKey)).width, leadingWidth); }); - testWidgets( + testWidgetsWithLeakTracking( 'SliverAppBar.medium collapsed title does not overlap with leading/actions widgets', (WidgetTester tester) async { const String title = 'Medium SliverAppBar Very Long Title'; @@ -4615,7 +4616,7 @@ void main() { expect(titleOffset.dx, lessThan(searchOffset.dx)); }); - testWidgets( + testWidgetsWithLeakTracking( 'SliverAppBar.large collapsed title does not overlap with leading/actions widgets', (WidgetTester tester) async { const String title = 'Large SliverAppBar Very Long Title'; @@ -4667,7 +4668,7 @@ void main() { expect(titleOffset.dx, lessThan(searchOffset.dx)); }); - testWidgets('SliverAppBar.medium respects title spacing', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar.medium respects title spacing', (WidgetTester tester) async { const String title = 'Medium SliverAppBar Very Long Title'; const double titleSpacing = 16.0; @@ -4760,7 +4761,7 @@ void main() { expect(titleOffset.dx, iconButtonOffset.dx); }); - testWidgets('SliverAppBar.large respects title spacing', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar.large respects title spacing', (WidgetTester tester) async { const String title = 'Large SliverAppBar Very Long Title'; const double titleSpacing = 16.0; @@ -4852,7 +4853,7 @@ void main() { expect(titleOffset.dx, iconButtonOffset.dx); }); - testWidgets( + testWidgetsWithLeakTracking( 'SliverAppBar.medium without the leading widget updates collapsed title padding', (WidgetTester tester) async { const String title = 'Medium SliverAppBar Title'; @@ -4914,7 +4915,7 @@ void main() { expect(titleOffset.dx, titleSpacing); }); - testWidgets( + testWidgetsWithLeakTracking( 'SliverAppBar.large without the leading widget updates collapsed title padding', (WidgetTester tester) async { const String title = 'Large SliverAppBar Title'; @@ -4976,7 +4977,7 @@ void main() { expect(titleOffset.dx, titleSpacing); }); - testWidgets( + testWidgetsWithLeakTracking( 'SliverAppBar large & medium title respects automaticallyImplyLeading', (WidgetTester tester) async { // This is a regression test for https://github.com/flutter/flutter/issues/121511 @@ -5034,7 +5035,7 @@ void main() { expect(titleOffset.dx, backButtonOffset.dx + titleSpacing); }); - testWidgets('SliverAppBar.medium with bottom widget', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar.medium with bottom widget', (WidgetTester tester) async { // This is a regression test for https://github.com/flutter/flutter/issues/115091 const double collapsedAppBarHeight = 64; const double expandedAppBarHeight = 112; @@ -5094,7 +5095,7 @@ void main() { expect(appBarHeight(tester), collapsedAppBarHeight + bottomHeight); }); - testWidgets('SliverAppBar.large with bottom widget', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar.large with bottom widget', (WidgetTester tester) async { // This is a regression test for https://github.com/flutter/flutter/issues/115091 const double collapsedAppBarHeight = 64; const double expandedAppBarHeight = 152; @@ -5154,7 +5155,7 @@ void main() { expect(appBarHeight(tester), collapsedAppBarHeight + bottomHeight); }); - testWidgets('SliverAppBar.medium expanded title has upper limit on text scaling', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar.medium expanded title has upper limit on text scaling', (WidgetTester tester) async { const String title = 'Medium AppBar'; Widget buildAppBar({double textScaleFactor = 1.0}) { return MaterialApp( @@ -5195,7 +5196,7 @@ void main() { _verifyTextNotClipped(expandedTitle, tester); }, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933 - testWidgets('SliverAppBar.large expanded title has upper limit on text scaling', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar.large expanded title has upper limit on text scaling', (WidgetTester tester) async { const String title = 'Large AppBar'; Widget buildAppBar({double textScaleFactor = 1.0}) { return MaterialApp( @@ -5233,7 +5234,7 @@ void main() { expect(tester.getRect(expandedTitle).height, closeTo(48.0, 0.1)); }, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933 - testWidgets('SliverAppBar.medium expanded title position is adjusted with textScaleFactor', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar.medium expanded title position is adjusted with textScaleFactor', (WidgetTester tester) async { const String title = 'Medium AppBar'; Widget buildAppBar({double textScaleFactor = 1.0}) { return MaterialApp( @@ -5274,7 +5275,7 @@ void main() { _verifyTextNotClipped(expandedTitle, tester); }, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933 - testWidgets('SliverAppBar.large expanded title position is adjusted with textScaleFactor', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar.large expanded title position is adjusted with textScaleFactor', (WidgetTester tester) async { const String title = 'Large AppBar'; Widget buildAppBar({double textScaleFactor = 1.0}) { return MaterialApp( @@ -5358,7 +5359,7 @@ void main() { ); } - testWidgets( + testWidgetsWithLeakTracking( 'forceMaterialTransparency == true allows gestures beneath the app bar', (WidgetTester tester) async { bool buttonWasPressed = false; final Widget widget = buildWidget( @@ -5376,7 +5377,7 @@ void main() { expect(buttonWasPressed, isTrue); }); - testWidgets( + testWidgetsWithLeakTracking( 'forceMaterialTransparency == false does not allow gestures beneath the app bar', (WidgetTester tester) async { // Set this, and tester.tap(warnIfMissed:false), to suppress @@ -5405,7 +5406,7 @@ void main() { // support is deprecated and the APIs are removed, these tests // can be deleted. - testWidgets('Material2 - SliverAppBar.medium defaults', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material2 - SliverAppBar.medium defaults', (WidgetTester tester) async { final ThemeData theme = ThemeData(useMaterial3: false); const double collapsedAppBarHeight = 64; const double expandedAppBarHeight = 112; @@ -5489,7 +5490,7 @@ void main() { expect(tester.getSize(expandedTitleClip).height, expandedAppBarHeight - collapsedAppBarHeight); }); - testWidgets('Material2 - SliverAppBar.large defaults', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material2 - SliverAppBar.large defaults', (WidgetTester tester) async { final ThemeData theme = ThemeData(useMaterial3: false); const double collapsedAppBarHeight = 64; const double expandedAppBarHeight = 152; diff --git a/packages/flutter/test/material/app_bar_theme_test.dart b/packages/flutter/test/material/app_bar_theme_test.dart index 3f1c076fb3..f73bd9f12d 100644 --- a/packages/flutter/test/material/app_bar_theme_test.dart +++ b/packages/flutter/test/material/app_bar_theme_test.dart @@ -7,6 +7,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; void main() { const AppBarTheme appBarTheme = AppBarTheme( @@ -42,7 +43,7 @@ void main() { expect(identical(AppBarTheme.lerp(data, data, 0.5), data), true); }); - testWidgets('Material2 - Passing no AppBarTheme returns defaults', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material2 - Passing no AppBarTheme returns defaults', (WidgetTester tester) async { final ThemeData theme = ThemeData(useMaterial3: false); await tester.pumpWidget( MaterialApp( @@ -77,7 +78,7 @@ void main() { expect(tester.getSize(find.byType(AppBar)).width, 800); }); - testWidgets('Material3 - Passing no AppBarTheme returns defaults', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - Passing no AppBarTheme returns defaults', (WidgetTester tester) async { final ThemeData theme = ThemeData(useMaterial3: true); await tester.pumpWidget( MaterialApp( @@ -117,7 +118,7 @@ void main() { expect(tester.getSize(find.byType(AppBar)).width, 800); }); - testWidgets('AppBar uses values from AppBarTheme', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar uses values from AppBarTheme', (WidgetTester tester) async { final AppBarTheme appBarTheme = _appBarTheme(); await tester.pumpWidget( @@ -154,7 +155,7 @@ void main() { expect(tester.getSize(find.byType(AppBar)).width, 800); }); - testWidgets('AppBar widget properties take priority over theme', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar widget properties take priority over theme', (WidgetTester tester) async { const Brightness brightness = Brightness.dark; const SystemUiOverlayStyle systemOverlayStyle = SystemUiOverlayStyle.light; const Color color = Colors.orange; @@ -210,7 +211,7 @@ void main() { expect(text.style, toolbarTextStyle); }); - testWidgets('AppBar icon color takes priority over everything', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar icon color takes priority over everything', (WidgetTester tester) async { const Color color = Colors.lime; const IconThemeData iconThemeData = IconThemeData(color: Colors.green); const IconThemeData actionsIconThemeData = IconThemeData(color: Colors.lightBlue); @@ -230,7 +231,7 @@ void main() { expect(actionIconText.text.style!.color, color); }); - testWidgets('AppBarTheme properties take priority over ThemeData properties', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBarTheme properties take priority over ThemeData properties', (WidgetTester tester) async { final AppBarTheme appBarTheme = _appBarTheme(); await tester.pumpWidget( @@ -264,7 +265,7 @@ void main() { expect(text.style, appBarTheme.toolbarTextStyle); }); - testWidgets('Material2 - ThemeData colorScheme is used when no AppBarTheme is set', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material2 - ThemeData colorScheme is used when no AppBarTheme is set', (WidgetTester tester) async { final ThemeData lightTheme = ThemeData.from(colorScheme: const ColorScheme.light(), useMaterial3: false); final ThemeData darkTheme = ThemeData.from(colorScheme: const ColorScheme.dark(), useMaterial3: false); Widget buildFrame(ThemeData appTheme) { @@ -338,7 +339,7 @@ void main() { expect(text.style, Typography.material2014().englishLike.bodyMedium!.merge(Typography.material2014().black.bodyMedium).copyWith(color: darkTheme.colorScheme.onSurface)); }); - testWidgets('Material3 - ThemeData colorScheme is used when no AppBarTheme is set', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - ThemeData colorScheme is used when no AppBarTheme is set', (WidgetTester tester) async { final ThemeData lightTheme = ThemeData.from(colorScheme: const ColorScheme.light(), useMaterial3: true); final ThemeData darkTheme = ThemeData.from(colorScheme: const ColorScheme.dark(), useMaterial3: true); Widget buildFrame(ThemeData appTheme) { @@ -412,7 +413,7 @@ void main() { expect(text.style, Typography.material2021().englishLike.bodyMedium!.merge(Typography.material2021().black.bodyMedium).copyWith(color: darkTheme.colorScheme.onSurface, decorationColor: darkTheme.colorScheme.onSurface)); }); - testWidgets('AppBar iconTheme with color=null defers to outer IconTheme', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar iconTheme with color=null defers to outer IconTheme', (WidgetTester tester) async { // Verify claim made in https://github.com/flutter/flutter/pull/71184#issuecomment-737419215 Widget buildFrame({ Color? appIconColor, Color? appBarIconColor }) { @@ -452,7 +453,7 @@ void main() { expect(getIconText().text.style!.color, Colors.purple); }); - testWidgets('AppBar uses AppBarTheme.centerTitle when centerTitle is null', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar uses AppBarTheme.centerTitle when centerTitle is null', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp( theme: ThemeData(appBarTheme: const AppBarTheme(centerTitle: true)), home: Scaffold(appBar: AppBar( @@ -464,7 +465,7 @@ void main() { expect(navToolBar.centerMiddle, true); }); - testWidgets('AppBar.centerTitle takes priority over AppBarTheme.centerTitle', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar.centerTitle takes priority over AppBarTheme.centerTitle', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp( theme: ThemeData(appBarTheme: const AppBarTheme(centerTitle: true)), home: Scaffold( @@ -480,7 +481,7 @@ void main() { expect(navToolBar.centerMiddle, false); }); - testWidgets('AppBar.centerTitle adapts to TargetPlatform when AppBarTheme.centerTitle is null', (WidgetTester tester) async{ + testWidgetsWithLeakTracking('AppBar.centerTitle adapts to TargetPlatform when AppBarTheme.centerTitle is null', (WidgetTester tester) async{ await tester.pumpWidget(MaterialApp( theme: ThemeData(platform: TargetPlatform.iOS), home: Scaffold(appBar: AppBar( @@ -494,7 +495,7 @@ void main() { expect(navToolBar.centerMiddle, true); }); - testWidgets('AppBar.shadowColor takes priority over AppBarTheme.shadowColor', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar.shadowColor takes priority over AppBarTheme.shadowColor', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp( theme: ThemeData(appBarTheme: const AppBarTheme(shadowColor: Colors.red)), home: Scaffold( @@ -510,7 +511,7 @@ void main() { expect(appBar.shadowColor, Colors.yellow); }); - testWidgets('AppBar.surfaceTintColor takes priority over AppBarTheme.surfaceTintColor', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar.surfaceTintColor takes priority over AppBarTheme.surfaceTintColor', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp( theme: ThemeData(appBarTheme: const AppBarTheme(surfaceTintColor: Colors.red)), home: Scaffold( @@ -526,7 +527,7 @@ void main() { expect(appBar.surfaceTintColor, Colors.yellow); }); - testWidgets('Material3 - AppBarTheme.iconTheme.color takes priority over IconButtonTheme.foregroundColor', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBarTheme.iconTheme.color takes priority over IconButtonTheme.foregroundColor', (WidgetTester tester) async { const IconThemeData overallIconTheme = IconThemeData(color: Colors.yellow); await tester.pumpWidget(MaterialApp( theme: ThemeData( @@ -552,7 +553,7 @@ void main() { expect(actionIconButtonColor, overallIconTheme.color); }); - testWidgets('Material3 - AppBarTheme.iconTheme.size takes priority over IconButtonTheme.iconSize', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBarTheme.iconTheme.size takes priority over IconButtonTheme.iconSize', (WidgetTester tester) async { const IconThemeData overallIconTheme = IconThemeData(size: 30.0); await tester.pumpWidget(MaterialApp( theme: ThemeData( @@ -579,7 +580,7 @@ void main() { }); - testWidgets('Material3 - AppBarTheme.actionsIconTheme.color takes priority over IconButtonTheme.foregroundColor', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBarTheme.actionsIconTheme.color takes priority over IconButtonTheme.foregroundColor', (WidgetTester tester) async { const IconThemeData actionsIconTheme = IconThemeData(color: Colors.yellow); final IconButtonThemeData iconButtonTheme = IconButtonThemeData( style: IconButton.styleFrom(foregroundColor: Colors.red), @@ -607,7 +608,7 @@ void main() { expect(actionIconButtonColor, actionsIconTheme.color); }); - testWidgets('Material3 - AppBarTheme.actionsIconTheme.size takes priority over IconButtonTheme.iconSize', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBarTheme.actionsIconTheme.size takes priority over IconButtonTheme.iconSize', (WidgetTester tester) async { const IconThemeData actionsIconTheme = IconThemeData(size: 30.0); final IconButtonThemeData iconButtonTheme = IconButtonThemeData( style: IconButton.styleFrom(iconSize: 32.0), @@ -634,7 +635,7 @@ void main() { expect(actionIconButtonSize, actionsIconTheme.size); }); - testWidgets('Material3 - AppBarTheme.foregroundColor takes priority over IconButtonTheme.foregroundColor', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBarTheme.foregroundColor takes priority over IconButtonTheme.foregroundColor', (WidgetTester tester) async { final IconButtonThemeData iconButtonTheme = IconButtonThemeData( style: IconButton.styleFrom(foregroundColor: Colors.red), ); @@ -669,7 +670,7 @@ void main() { expect(actionIconButtonColor, appBarTheme.foregroundColor); }); - testWidgets('AppBar uses AppBarTheme.titleSpacing', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar uses AppBarTheme.titleSpacing', (WidgetTester tester) async { const double kTitleSpacing = 10; await tester.pumpWidget(MaterialApp( theme: ThemeData(appBarTheme: const AppBarTheme(titleSpacing: kTitleSpacing)), @@ -684,7 +685,7 @@ void main() { expect(navToolBar.middleSpacing, kTitleSpacing); }); - testWidgets('AppBar.titleSpacing takes priority over AppBarTheme.titleSpacing', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBar.titleSpacing takes priority over AppBarTheme.titleSpacing', (WidgetTester tester) async { const double kTitleSpacing = 10; await tester.pumpWidget(MaterialApp( theme: ThemeData(appBarTheme: const AppBarTheme(titleSpacing: kTitleSpacing)), @@ -700,7 +701,7 @@ void main() { expect(navToolBar.middleSpacing, 40); }); - testWidgets('SliverAppBar uses AppBarTheme.titleSpacing', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar uses AppBarTheme.titleSpacing', (WidgetTester tester) async { const double kTitleSpacing = 10; await tester.pumpWidget(MaterialApp( theme: ThemeData(appBarTheme: const AppBarTheme(titleSpacing: kTitleSpacing)), @@ -717,7 +718,7 @@ void main() { expect(navToolBar.middleSpacing, kTitleSpacing); }); - testWidgets('SliverAppBar.titleSpacing takes priority over AppBarTheme.titleSpacing ', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar.titleSpacing takes priority over AppBarTheme.titleSpacing ', (WidgetTester tester) async { const double kTitleSpacing = 10; await tester.pumpWidget(MaterialApp( theme: ThemeData(appBarTheme: const AppBarTheme(titleSpacing: kTitleSpacing)), @@ -735,7 +736,7 @@ void main() { expect(navToolbar.middleSpacing, 40); }); - testWidgets('SliverAppBar.medium uses AppBarTheme properties', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar.medium uses AppBarTheme properties', (WidgetTester tester) async { const String title = 'Medium App Bar'; await tester.pumpWidget(MaterialApp( @@ -791,7 +792,7 @@ void main() { expect(titleOffset.dx, iconOffset.dx + appBarTheme.titleSpacing!); }); - testWidgets('SliverAppBar.medium properties take priority over AppBarTheme properties', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar.medium properties take priority over AppBarTheme properties', (WidgetTester tester) async { const String title = 'Medium App Bar'; const Color backgroundColor = Color(0xff000099); const Color foregroundColor = Color(0xff00ff98); @@ -868,7 +869,7 @@ void main() { expect(titleOffset.dx, iconOffset.dx + titleSpacing); }); - testWidgets('SliverAppBar.large uses AppBarTheme properties', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar.large uses AppBarTheme properties', (WidgetTester tester) async { const String title = 'Large App Bar'; await tester.pumpWidget(MaterialApp( @@ -924,7 +925,7 @@ void main() { expect(titleOffset.dx, iconOffset.dx + appBarTheme.titleSpacing!); }); - testWidgets('SliverAppBar.large properties take priority over AppBarTheme properties', (WidgetTester tester) async { + testWidgetsWithLeakTracking('SliverAppBar.large properties take priority over AppBarTheme properties', (WidgetTester tester) async { const String title = 'Large App Bar'; const Color backgroundColor = Color(0xff000099); const Color foregroundColor = Color(0xff00ff98); @@ -1001,7 +1002,7 @@ void main() { expect(titleOffset.dx, iconOffset.dx + titleSpacing); }); - testWidgets( + testWidgetsWithLeakTracking( 'SliverAppBar medium & large supports foregroundColor', (WidgetTester tester) async { const String title = 'AppBar title'; const AppBarTheme appBarTheme = AppBarTheme(foregroundColor: Color(0xff00ff20)); @@ -1045,7 +1046,7 @@ void main() { expect(largeTitle.text.style!.color, foregroundColor); }); - testWidgets('Default AppBarTheme debugFillProperties', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Default AppBarTheme debugFillProperties', (WidgetTester tester) async { final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); const AppBarTheme().debugFillProperties(builder); @@ -1057,7 +1058,7 @@ void main() { expect(description, []); }); - testWidgets('AppBarTheme implements debugFillProperties', (WidgetTester tester) async { + testWidgetsWithLeakTracking('AppBarTheme implements debugFillProperties', (WidgetTester tester) async { final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); const AppBarTheme( backgroundColor: Color(0xff000000), @@ -1112,7 +1113,7 @@ void main() { }, skip: kIsWeb); // https://github.com/flutter/flutter/issues/87364 // This is a regression test for https://github.com/flutter/flutter/issues/130485. - testWidgets('Material3 - AppBarTheme.iconTheme correctly applies custom white color in dark mode', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - AppBarTheme.iconTheme correctly applies custom white color in dark mode', (WidgetTester tester) async { final ThemeData themeData = ThemeData( useMaterial3: true, brightness: Brightness.dark, diff --git a/packages/flutter/test/material/app_test.dart b/packages/flutter/test/material/app_test.dart index d22565e195..cfad6de21e 100644 --- a/packages/flutter/test/material/app_test.dart +++ b/packages/flutter/test/material/app_test.dart @@ -8,6 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; class StateMarker extends StatefulWidget { const StateMarker({ super.key, this.child }); @@ -31,7 +32,7 @@ class StateMarkerState extends State { } void main() { - testWidgets('Can nest apps', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Can nest apps', (WidgetTester tester) async { await tester.pumpWidget( const MaterialApp( home: MaterialApp( @@ -43,7 +44,7 @@ void main() { expect(find.text('Home sweet home'), findsOneWidget); }); - testWidgets('Focus handling', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Focus handling', (WidgetTester tester) async { final FocusNode focusNode = FocusNode(); await tester.pumpWidget(MaterialApp( home: Material( @@ -70,7 +71,7 @@ void main() { expect(find.text('Home'), findsOneWidget); }); - testWidgets('Can show grid without losing sync', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Can show grid without losing sync', (WidgetTester tester) async { await tester.pumpWidget( const MaterialApp( home: StateMarker(), @@ -92,7 +93,7 @@ void main() { expect(state2.marker, equals('original')); }); - testWidgets('Do not rebuild page during a route transition', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Do not rebuild page during a route transition', (WidgetTester tester) async { int buildCounter = 0; await tester.pumpWidget( MaterialApp( @@ -137,7 +138,7 @@ void main() { expect(find.text('Y'), findsOneWidget); }); - testWidgets('Do rebuild the home page if it changes', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Do rebuild the home page if it changes', (WidgetTester tester) async { int buildCounter = 0; await tester.pumpWidget( MaterialApp( @@ -165,7 +166,7 @@ void main() { expect(find.text('B'), findsOneWidget); }); - testWidgets('Do not rebuild the home page if it does not actually change', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Do not rebuild the home page if it does not actually change', (WidgetTester tester) async { int buildCounter = 0; final Widget home = Builder( builder: (BuildContext context) { @@ -187,7 +188,7 @@ void main() { expect(buildCounter, 1); }); - testWidgets('Do rebuild pages that come from the routes table if the MaterialApp changes', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Do rebuild pages that come from the routes table if the MaterialApp changes', (WidgetTester tester) async { int buildCounter = 0; final Map routes = { '/': (BuildContext context) { @@ -209,7 +210,7 @@ void main() { expect(buildCounter, 2); }); - testWidgets('Cannot pop the initial route', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Cannot pop the initial route', (WidgetTester tester) async { await tester.pumpWidget(const MaterialApp(home: Text('Home'))); expect(find.text('Home'), findsOneWidget); @@ -222,7 +223,7 @@ void main() { expect(find.text('Home'), findsOneWidget); }); - testWidgets('Default initialRoute', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Default initialRoute', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp(routes: { '/': (BuildContext context) => const Text('route "/"'), })); @@ -230,7 +231,7 @@ void main() { expect(find.text('route "/"'), findsOneWidget); }); - testWidgets('One-step initial route', (WidgetTester tester) async { + testWidgetsWithLeakTracking('One-step initial route', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( initialRoute: '/a', @@ -249,7 +250,7 @@ void main() { expect(find.text('route "/b"', skipOffstage: false), findsNothing); }); - testWidgets('Return value from pop is correct', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Return value from pop is correct', (WidgetTester tester) async { late Future result; await tester.pumpWidget( MaterialApp( @@ -289,7 +290,7 @@ void main() { expect(await result, equals('all done')); }); - testWidgets('Two-step initial route', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Two-step initial route', (WidgetTester tester) async { final Map routes = { '/': (BuildContext context) => const Text('route "/"'), '/a': (BuildContext context) => const Text('route "/a"'), @@ -334,7 +335,7 @@ void main() { } }); - testWidgets('Make sure initialRoute is only used the first time', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Make sure initialRoute is only used the first time', (WidgetTester tester) async { final Map routes = { '/': (BuildContext context) => const Text('route "/"'), '/a': (BuildContext context) => const Text('route "/a"'), @@ -369,7 +370,7 @@ void main() { expect(find.text('route "/b"', skipOffstage: false), findsNothing); }); - testWidgets('onGenerateRoute / onUnknownRoute', (WidgetTester tester) async { + testWidgetsWithLeakTracking('onGenerateRoute / onUnknownRoute', (WidgetTester tester) async { final List log = []; await tester.pumpWidget( MaterialApp( @@ -391,7 +392,7 @@ void main() { expect(tester.takeException(), isAssertionError); }); - testWidgets('MaterialApp with builder and no route information works.', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp with builder and no route information works.', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/18904 await tester.pumpWidget( MaterialApp( @@ -402,7 +403,7 @@ void main() { ); }); - testWidgets("WidgetsApp doesn't rebuild routes when MediaQuery updates", (WidgetTester tester) async { + testWidgetsWithLeakTracking("WidgetsApp doesn't rebuild routes when MediaQuery updates", (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/37878 addTearDown(tester.platformDispatcher.clearAllTestValues); addTearDown(tester.view.reset); @@ -462,7 +463,7 @@ void main() { expect(dependentBuildCount, equals(5)); }); - testWidgets('Can get text scale from media query', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Can get text scale from media query', (WidgetTester tester) async { TextScaler? textScaler; await tester.pumpWidget(MaterialApp( home: Builder(builder:(BuildContext context) { @@ -473,7 +474,7 @@ void main() { expect(textScaler, TextScaler.noScaling); }); - testWidgets('MaterialApp.navigatorKey', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp.navigatorKey', (WidgetTester tester) async { final GlobalKey key = GlobalKey(); await tester.pumpWidget(MaterialApp( navigatorKey: key, @@ -494,7 +495,7 @@ void main() { expect(key.currentState, isA()); }); - testWidgets('Has default material and cupertino localizations', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Has default material and cupertino localizations', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: Builder( @@ -516,7 +517,7 @@ void main() { expect(find.text('Select All'), findsOneWidget); }); - testWidgets('MaterialApp uses regular theme when themeMode is light', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp uses regular theme when themeMode is light', (WidgetTester tester) async { addTearDown(tester.platformDispatcher.clearAllTestValues); // Mock the test to explicitly report a light platformBrightness. @@ -564,7 +565,7 @@ void main() { expect(appliedTheme.brightness, Brightness.light); }); - testWidgets('MaterialApp uses darkTheme when themeMode is dark', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp uses darkTheme when themeMode is dark', (WidgetTester tester) async { addTearDown(tester.platformDispatcher.clearAllTestValues); // Mock the test to explicitly report a light platformBrightness. @@ -612,7 +613,7 @@ void main() { expect(appliedTheme.brightness, Brightness.dark); }); - testWidgets('MaterialApp uses regular theme when themeMode is system and platformBrightness is light', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp uses regular theme when themeMode is system and platformBrightness is light', (WidgetTester tester) async { addTearDown(tester.platformDispatcher.clearAllTestValues); // Mock the test to explicitly report a light platformBrightness. @@ -640,7 +641,7 @@ void main() { expect(appliedTheme.brightness, Brightness.light); }); - testWidgets('MaterialApp uses darkTheme when themeMode is system and platformBrightness is dark', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp uses darkTheme when themeMode is system and platformBrightness is dark', (WidgetTester tester) async { addTearDown(tester.platformDispatcher.clearAllTestValues); // Mock the test to explicitly report a dark platformBrightness. @@ -666,7 +667,7 @@ void main() { expect(appliedTheme.brightness, Brightness.dark); }); - testWidgets('MaterialApp uses light theme when platformBrightness is dark but no dark theme is provided', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp uses light theme when platformBrightness is dark but no dark theme is provided', (WidgetTester tester) async { addTearDown(tester.platformDispatcher.clearAllTestValues); // Mock the test to explicitly report a dark platformBrightness. @@ -691,7 +692,7 @@ void main() { expect(appliedTheme.brightness, Brightness.light); }); - testWidgets('MaterialApp uses fallback light theme when platformBrightness is dark but no theme is provided at all', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp uses fallback light theme when platformBrightness is dark but no theme is provided at all', (WidgetTester tester) async { addTearDown(tester.platformDispatcher.clearAllTestValues); // Mock the test to explicitly report a dark platformBrightness. @@ -713,7 +714,7 @@ void main() { expect(appliedTheme.brightness, Brightness.light); }); - testWidgets('MaterialApp uses fallback light theme when platformBrightness is light and a dark theme is provided', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp uses fallback light theme when platformBrightness is light and a dark theme is provided', (WidgetTester tester) async { addTearDown(tester.platformDispatcher.clearAllTestValues); // Mock the test to explicitly report a dark platformBrightness. @@ -738,7 +739,7 @@ void main() { expect(appliedTheme.brightness, Brightness.light); }); - testWidgets('MaterialApp uses dark theme when platformBrightness is dark', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp uses dark theme when platformBrightness is dark', (WidgetTester tester) async { addTearDown(tester.platformDispatcher.clearAllTestValues); // Mock the test to explicitly report a dark platformBrightness. @@ -766,7 +767,7 @@ void main() { expect(appliedTheme.brightness, Brightness.dark); }); - testWidgets('MaterialApp uses high contrast theme when appropriate', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp uses high contrast theme when appropriate', (WidgetTester tester) async { addTearDown(tester.platformDispatcher.clearAllTestValues); tester.platformDispatcher.platformBrightnessTestValue = Brightness.light; @@ -794,7 +795,7 @@ void main() { expect(appliedTheme.primaryColor, Colors.blue); }); - testWidgets('MaterialApp uses high contrast dark theme when appropriate', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp uses high contrast dark theme when appropriate', (WidgetTester tester) async { addTearDown(tester.platformDispatcher.clearAllTestValues); tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark; @@ -828,7 +829,7 @@ void main() { expect(appliedTheme.primaryColor, Colors.green); }); - testWidgets('MaterialApp uses dark theme when no high contrast dark theme is provided', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp uses dark theme when no high contrast dark theme is provided', (WidgetTester tester) async { addTearDown(tester.platformDispatcher.clearAllTestValues); tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark; @@ -856,7 +857,7 @@ void main() { expect(appliedTheme.primaryColor, Colors.lightGreen); }); - testWidgets('MaterialApp animates theme changes', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp animates theme changes', (WidgetTester tester) async { final ThemeData lightTheme = ThemeData.light(); final ThemeData darkTheme = ThemeData.dark(); await tester.pumpWidget( @@ -896,7 +897,7 @@ void main() { expect(tester.widget(find.byType(Material)).color, halfBGColor); }); - testWidgets('MaterialApp theme animation can be turned off', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp theme animation can be turned off', (WidgetTester tester) async { final ThemeData lightTheme = ThemeData.light(); final ThemeData darkTheme = ThemeData.dark(); int scaffoldRebuilds = 0; @@ -938,7 +939,7 @@ void main() { expect(scaffoldRebuilds, 2); }); - testWidgets('MaterialApp switches themes when the platformBrightness changes.', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp switches themes when the platformBrightness changes.', (WidgetTester tester) async { addTearDown(tester.platformDispatcher.clearAllTestValues); // Mock the test to explicitly report a light platformBrightness. @@ -977,7 +978,7 @@ void main() { expect(themeAfterBrightnessChange!.brightness, Brightness.dark); }); - testWidgets('Material2 - MaterialApp provides default overscroll color', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material2 - MaterialApp provides default overscroll color', (WidgetTester tester) async { Future slowDrag(WidgetTester tester, Offset start, Offset offset) async { final TestGesture gesture = await tester.startGesture(start); for (int index = 0; index < 10; index += 1) { @@ -1009,7 +1010,7 @@ void main() { expect(painter, paints..circle(color: glowSecondaryColor)); }); - testWidgets('MaterialApp can customize initial routes', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp can customize initial routes', (WidgetTester tester) async { final GlobalKey navigatorKey = GlobalKey(); await tester.pumpWidget( MaterialApp( @@ -1056,7 +1057,7 @@ void main() { expect(find.text('regular page two'), findsNothing); }); - testWidgets('MaterialApp does create HeroController with the MaterialRectArcTween', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp does create HeroController with the MaterialRectArcTween', (WidgetTester tester) async { final HeroController controller = MaterialApp.createMaterialHeroController(); final Tween tween = controller.createRectTween!( const Rect.fromLTRB(0.0, 0.0, 10.0, 10.0), @@ -1065,7 +1066,7 @@ void main() { expect(tween, isA()); }); - testWidgets('MaterialApp.navigatorKey can be updated', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp.navigatorKey can be updated', (WidgetTester tester) async { final GlobalKey key1 = GlobalKey(); await tester.pumpWidget(MaterialApp( navigatorKey: key1, @@ -1137,7 +1138,7 @@ void main() { expect(find.text('popped'), findsOneWidget); }); - testWidgets('MaterialApp.router throw if route information provider is provided but no route information parser', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp.router throw if route information provider is provided but no route information parser', (WidgetTester tester) async { final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate( builder: (BuildContext context, RouteInformation information) { return Text(information.uri.toString()); @@ -1162,7 +1163,7 @@ void main() { expect(tester.takeException(), isAssertionError); }); - testWidgets('MaterialApp.router throw if route configuration is provided along with other delegate', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp.router throw if route configuration is provided along with other delegate', (WidgetTester tester) async { final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate( builder: (BuildContext context, RouteInformation information) { return Text(information.uri.toString()); @@ -1216,7 +1217,7 @@ void main() { expect(find.text('popped'), findsOneWidget); }); - testWidgets('MaterialApp.builder can build app without a Navigator', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp.builder can build app without a Navigator', (WidgetTester tester) async { Widget? builderChild; await tester.pumpWidget(MaterialApp( builder: (BuildContext context, Widget? child) { @@ -1227,7 +1228,7 @@ void main() { expect(builderChild, isNull); }); - testWidgets('MaterialApp has correct default ScrollBehavior', (WidgetTester tester) async { + testWidgetsWithLeakTracking('MaterialApp has correct default ScrollBehavior', (WidgetTester tester) async { late BuildContext capturedContext; await tester.pumpWidget( MaterialApp( @@ -1242,7 +1243,7 @@ void main() { expect(ScrollConfiguration.of(capturedContext).runtimeType, MaterialScrollBehavior); }); - testWidgets('A ScrollBehavior can be set for MaterialApp', (WidgetTester tester) async { + testWidgetsWithLeakTracking('A ScrollBehavior can be set for MaterialApp', (WidgetTester tester) async { late BuildContext capturedContext; await tester.pumpWidget( MaterialApp( @@ -1260,7 +1261,7 @@ void main() { expect(scrollBehavior.getScrollPhysics(capturedContext).runtimeType, NeverScrollableScrollPhysics); }); - testWidgets('Material2 - ScrollBehavior default android overscroll indicator', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material2 - ScrollBehavior default android overscroll indicator', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp( theme: ThemeData(useMaterial3: false), scrollBehavior: const MaterialScrollBehavior(), @@ -1279,7 +1280,7 @@ void main() { expect(find.byType(GlowingOverscrollIndicator), findsOneWidget); }, variant: TargetPlatformVariant.only(TargetPlatform.android)); - testWidgets('Material3 - ScrollBehavior default android overscroll indicator', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - ScrollBehavior default android overscroll indicator', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp( theme: ThemeData(useMaterial3: true), scrollBehavior: const MaterialScrollBehavior(), @@ -1298,7 +1299,7 @@ void main() { expect(find.byType(GlowingOverscrollIndicator), findsNothing); }, variant: TargetPlatformVariant.only(TargetPlatform.android)); - testWidgets('ScrollBehavior stretch android overscroll indicator', (WidgetTester tester) async { + testWidgetsWithLeakTracking('ScrollBehavior stretch android overscroll indicator', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp( scrollBehavior: const MaterialScrollBehavior(androidOverscrollIndicator: AndroidOverscrollIndicator.stretch), home: ListView( @@ -1316,7 +1317,7 @@ void main() { expect(find.byType(GlowingOverscrollIndicator), findsNothing); }, variant: TargetPlatformVariant.only(TargetPlatform.android)); - testWidgets('Overscroll indicator can be set by theme', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Overscroll indicator can be set by theme', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp( // The current default is glowing, setting via the theme should override. theme: ThemeData().copyWith(androidOverscrollIndicator: AndroidOverscrollIndicator.stretch), @@ -1335,7 +1336,7 @@ void main() { expect(find.byType(GlowingOverscrollIndicator), findsNothing); }, variant: TargetPlatformVariant.only(TargetPlatform.android)); - testWidgets('Overscroll indicator in MaterialScrollBehavior takes precedence over theme', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Overscroll indicator in MaterialScrollBehavior takes precedence over theme', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp( // MaterialScrollBehavior.androidOverscrollIndicator takes precedence over theme. scrollBehavior: const MaterialScrollBehavior(androidOverscrollIndicator: AndroidOverscrollIndicator.stretch), @@ -1355,7 +1356,7 @@ void main() { expect(find.byType(GlowingOverscrollIndicator), findsNothing); }, variant: TargetPlatformVariant.only(TargetPlatform.android)); - testWidgets('Material3 - ListView clip behavior updates overscroll indicator clip behavior', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - ListView clip behavior updates overscroll indicator clip behavior', (WidgetTester tester) async { Widget buildFrame(Clip clipBehavior) { return MaterialApp( theme: ThemeData(useMaterial3: true), @@ -1431,7 +1432,7 @@ void main() { await tester.pumpAndSettle(); }, variant: TargetPlatformVariant.only(TargetPlatform.android)); - testWidgets('When `useInheritedMediaQuery` is true an existing MediaQuery is used if one is available', (WidgetTester tester) async { + testWidgetsWithLeakTracking('When `useInheritedMediaQuery` is true an existing MediaQuery is used if one is available', (WidgetTester tester) async { late BuildContext capturedContext; final UniqueKey uniqueKey = UniqueKey(); await tester.pumpWidget( @@ -1451,7 +1452,7 @@ void main() { expect(capturedContext.dependOnInheritedWidgetOfExactType()?.key, uniqueKey); }); - testWidgets('Assert in buildScrollbar that controller != null when using it (vertical)', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Assert in buildScrollbar that controller != null when using it (vertical)', (WidgetTester tester) async { const ScrollBehavior defaultBehavior = MaterialScrollBehavior(); late BuildContext capturedContext; @@ -1496,7 +1497,7 @@ void main() { } }, variant: TargetPlatformVariant.all()); - testWidgets('Assert in buildScrollbar that controller != null when using it (horizontal)', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Assert in buildScrollbar that controller != null when using it (horizontal)', (WidgetTester tester) async { const ScrollBehavior defaultBehavior = MaterialScrollBehavior(); late BuildContext capturedContext; diff --git a/packages/flutter/test/material/back_button_test.dart b/packages/flutter/test/material/back_button_test.dart index 9ba330182c..164eaafee8 100644 --- a/packages/flutter/test/material/back_button_test.dart +++ b/packages/flutter/test/material/back_button_test.dart @@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; void main() { - testWidgets('BackButton control test', (WidgetTester tester) async { + testWidgetsWithLeakTracking('BackButton control test', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: const Material(child: Text('Home')), diff --git a/packages/flutter/test/material/radio_list_tile_test.dart b/packages/flutter/test/material/radio_list_tile_test.dart index 84fcbe5d35..6507c250cb 100644 --- a/packages/flutter/test/material/radio_list_tile_test.dart +++ b/packages/flutter/test/material/radio_list_tile_test.dart @@ -8,6 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; import '../widgets/semantics_tester.dart'; import 'feedback_tester.dart'; @@ -23,7 +24,7 @@ Widget wrap({Widget? child}) { } void main() { - testWidgets('RadioListTile should initialize according to groupValue', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile should initialize according to groupValue', (WidgetTester tester) async { final List values = [0, 1, 2]; int? selectedValue; // Constructor parameters are required for [RadioListTile], but they are @@ -83,7 +84,7 @@ void main() { expect(generatedRadioListTiles[2].checked, equals(false)); }); - testWidgets('RadioListTile simple control test', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile simple control test', (WidgetTester tester) async { final Key key = UniqueKey(); final Key titleKey = UniqueKey(); final List log = []; @@ -155,7 +156,7 @@ void main() { expect(log, equals([1])); }); - testWidgets('RadioListTile control tests', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile control tests', (WidgetTester tester) async { final List values = [0, 1, 2]; int? selectedValue; // Constructor parameters are required for [Radio], but they are irrelevant @@ -222,7 +223,7 @@ void main() { expect(log, equals([1, '-', 2])); }); - testWidgets('Selected RadioListTile should not trigger onChanged', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Selected RadioListTile should not trigger onChanged', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/30311 final List values = [0, 1, 2]; int? selectedValue; @@ -274,7 +275,7 @@ void main() { expect(log, equals([0])); }); - testWidgets('Selected RadioListTile should trigger onChanged when toggleable', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Selected RadioListTile should trigger onChanged when toggleable', (WidgetTester tester) async { final List values = [0, 1, 2]; int? selectedValue; // Constructor parameters are required for [Radio], but they are irrelevant @@ -328,7 +329,7 @@ void main() { expect(log, equals([0, null, 0])); }); - testWidgets('RadioListTile can be toggled when toggleable is set', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile can be toggled when toggleable is set', (WidgetTester tester) async { final Key key = UniqueKey(); final List log = []; @@ -383,7 +384,7 @@ void main() { expect(log, equals([1])); }); - testWidgets('RadioListTile semantics', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile semantics', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( @@ -532,7 +533,7 @@ void main() { semantics.dispose(); }); - testWidgets('RadioListTile has semantic events', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile has semantic events', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); final Key key = UniqueKey(); dynamic semanticEvent; @@ -571,7 +572,7 @@ void main() { tester.binding.defaultBinaryMessenger.setMockDecodedMessageHandler(SystemChannels.accessibility, null); }); - testWidgets('RadioListTile can autofocus unless disabled.', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile can autofocus unless disabled.', (WidgetTester tester) async { final GlobalKey childKey = GlobalKey(); await tester.pumpWidget( @@ -605,7 +606,7 @@ void main() { expect(Focus.of(childKey.currentContext!).hasPrimaryFocus, isFalse); }); - testWidgets('RadioListTile contentPadding test', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile contentPadding test', (WidgetTester tester) async { final Type radioType = const Radio( groupValue: true, value: true, @@ -645,7 +646,7 @@ void main() { expect(paddingRect.right, titleRect.right + 15); //right padding }); - testWidgets('RadioListTile respects shape', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile respects shape', (WidgetTester tester) async { const ShapeBorder shapeBorder = RoundedRectangleBorder( borderRadius: BorderRadius.horizontal(right: Radius.circular(100)), ); @@ -665,7 +666,7 @@ void main() { expect(tester.widget(find.byType(InkWell)).customBorder, shapeBorder); }); - testWidgets('RadioListTile respects tileColor', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile respects tileColor', (WidgetTester tester) async { final Color tileColor = Colors.red.shade500; await tester.pumpWidget( @@ -685,7 +686,7 @@ void main() { expect(find.byType(Material), paints..rect(color: tileColor)); }); - testWidgets('RadioListTile respects selectedTileColor', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile respects selectedTileColor', (WidgetTester tester) async { final Color selectedTileColor = Colors.green.shade500; await tester.pumpWidget( @@ -706,7 +707,7 @@ void main() { expect(find.byType(Material), paints..rect(color: selectedTileColor)); }); - testWidgets('RadioListTile selected item text Color', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile selected item text Color', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/pull/76906 const Color activeColor = Color(0xff00ff00); @@ -746,7 +747,7 @@ void main() { expect(textColor('title'), activeColor); }); - testWidgets('RadioListTile respects visualDensity', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile respects visualDensity', (WidgetTester tester) async { const Key key = Key('test'); Future buildTest(VisualDensity visualDensity) async { return tester.pumpWidget( @@ -771,7 +772,7 @@ void main() { expect(box.size, equals(const Size(800, 56))); }); - testWidgets('RadioListTile respects focusNode', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile respects focusNode', (WidgetTester tester) async { final GlobalKey childKey = GlobalKey(); await tester.pumpWidget( wrap( @@ -824,7 +825,7 @@ void main() { expect(node.hasFocus, isFalse); }); - testWidgets('Radio changes mouse cursor when hovered', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Radio changes mouse cursor when hovered', (WidgetTester tester) async { // Test Radio() constructor await tester.pumpWidget( wrap(child: MouseRegion( @@ -875,7 +876,7 @@ void main() { expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic); }); - testWidgets('RadioListTile respects fillColor in enabled/disabled states', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile respects fillColor in enabled/disabled states', (WidgetTester tester) async { const Color activeEnabledFillColor = Color(0xFF000001); const Color activeDisabledFillColor = Color(0xFF000002); const Color inactiveEnabledFillColor = Color(0xFF000003); @@ -962,7 +963,7 @@ void main() { ); }); - testWidgets('RadioListTile respects fillColor in hovered state', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile respects fillColor in hovered state', (WidgetTester tester) async { tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; const Color hoveredFillColor = Color(0xFF000001); @@ -1011,7 +1012,7 @@ void main() { ); }); - testWidgets('Material3 - RadioListTile respects hoverColor', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - RadioListTile respects hoverColor', (WidgetTester tester) async { tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; int? groupValue = 0; final Color? hoverColor = Colors.orange[500]; @@ -1077,7 +1078,7 @@ void main() { ); }); - testWidgets('Material3 - RadioListTile respects overlayColor in active/pressed/hovered states', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material3 - RadioListTile respects overlayColor in active/pressed/hovered states', (WidgetTester tester) async { tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; const Color fillColor = Color(0xFF000000); @@ -1202,7 +1203,7 @@ void main() { ); }); - testWidgets('RadioListTile respects splashRadius', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile respects splashRadius', (WidgetTester tester) async { tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; const double splashRadius = 30; Widget buildApp() { @@ -1234,7 +1235,7 @@ void main() { ); }); - testWidgets('Radio respects materialTapTargetSize', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Radio respects materialTapTargetSize', (WidgetTester tester) async { await tester.pumpWidget( wrap(child: RadioListTile( groupValue: true, @@ -1258,7 +1259,7 @@ void main() { expect(tester.getSize(find.byType(Radio)), const Size(48.0, 48.0)); }); - testWidgets('RadioListTile.adaptive shows the correct radio platform widget', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile.adaptive shows the correct radio platform widget', (WidgetTester tester) async { Widget buildApp(TargetPlatform platform) { return MaterialApp( theme: ThemeData(platform: platform), @@ -1300,7 +1301,7 @@ void main() { feedback.dispose(); }); - testWidgets('RadioListTile respects enableFeedback', (WidgetTester tester) async { + testWidgetsWithLeakTracking('RadioListTile respects enableFeedback', (WidgetTester tester) async { const Key key = Key('test'); Future buildTest(bool enableFeedback) async { return tester.pumpWidget( @@ -1338,7 +1339,7 @@ void main() { // support is deprecated and the APIs are removed, these tests // can be deleted. - testWidgets('Material2 - RadioListTile respects overlayColor in active/pressed/hovered states', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material2 - RadioListTile respects overlayColor in active/pressed/hovered states', (WidgetTester tester) async { tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; const Color fillColor = Color(0xFF000000); @@ -1442,7 +1443,7 @@ void main() { ); }); - testWidgets('Material2 - RadioListTile respects hoverColor', (WidgetTester tester) async { + testWidgetsWithLeakTracking('Material2 - RadioListTile respects hoverColor', (WidgetTester tester) async { tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; int? groupValue = 0; final Color? hoverColor = Colors.orange[500];