Unverified Commit 4e6da2dc authored by Polina Cherkasova's avatar Polina Cherkasova Committed by GitHub

Cover more tests with leak tracking. (#132806)

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