diff --git a/packages/flutter/lib/src/material/snack_bar.dart b/packages/flutter/lib/src/material/snack_bar.dart index de80b2b45a71..5bed2ab347ce 100644 --- a/packages/flutter/lib/src/material/snack_bar.dart +++ b/packages/flutter/lib/src/material/snack_bar.dart @@ -842,11 +842,12 @@ class _SnackbarDefaultsM2 extends SnackBarThemeData { @override TextStyle? get contentTextStyle => ThemeData( - brightness: _theme.brightness == Brightness.light - ? Brightness.dark - : Brightness.light) - .textTheme - .titleMedium; + useMaterial3: _theme.useMaterial3, + brightness: _theme.brightness == Brightness.light + ? Brightness.dark + : Brightness.light) + .textTheme + .titleMedium; @override SnackBarBehavior get behavior => SnackBarBehavior.fixed; diff --git a/packages/flutter/test/material/dropdown_menu_test.dart b/packages/flutter/test/material/dropdown_menu_test.dart index 6ec5e480a5b5..50fba56e13b6 100644 --- a/packages/flutter/test/material/dropdown_menu_test.dart +++ b/packages/flutter/test/material/dropdown_menu_test.dart @@ -112,7 +112,7 @@ void main() { testWidgets('The width of the text field should always be the same as the menu view', (WidgetTester tester) async { - final ThemeData themeData = ThemeData(); + final ThemeData themeData = ThemeData(useMaterial3: false); final bool useMaterial3 = themeData.useMaterial3; await tester.pumpWidget( MaterialApp( diff --git a/packages/flutter/test/material/icon_button_test.dart b/packages/flutter/test/material/icon_button_test.dart index 6ca92b500eff..949a467b1be2 100644 --- a/packages/flutter/test/material/icon_button_test.dart +++ b/packages/flutter/test/material/icon_button_test.dart @@ -789,7 +789,7 @@ void main() { await tester.pumpWidget( wrap( - useMaterial3: theme.useMaterial3, + useMaterial3: false, child: Column( children: [ IconButton( diff --git a/packages/flutter/test/material/ink_sparkle_test.dart b/packages/flutter/test/material/ink_sparkle_test.dart index 6a76bb9a5361..6fea3242e3d3 100644 --- a/packages/flutter/test/material/ink_sparkle_test.dart +++ b/packages/flutter/test/material/ink_sparkle_test.dart @@ -116,6 +116,7 @@ Future _runTest(WidgetTester tester, String positionName, double distanceF final Key buttonKey = UniqueKey(); await tester.pumpWidget(MaterialApp( + theme: ThemeData(useMaterial3: false), home: Scaffold( body: Center( child: RepaintBoundary( diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index c5767468720b..a2c4b252c53a 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -4488,6 +4488,7 @@ void main() { // This is a regression test for https://github.com/flutter/flutter/issues/82321 Widget buildFrame(TextDirection textDirection) { return MaterialApp( + theme: ThemeData(useMaterial3: false), home: Scaffold( body: Container( padding: const EdgeInsets.all(16.0), @@ -4536,6 +4537,7 @@ void main() { Widget buildFrame(TextDirection textDirection) { return MaterialApp( + theme: ThemeData(useMaterial3: false), home: Scaffold( body: Container( padding: const EdgeInsets.all(16.0), diff --git a/packages/flutter/test/material/material_test.dart b/packages/flutter/test/material/material_test.dart index ba8a399d934f..f08733a29e57 100644 --- a/packages/flutter/test/material/material_test.dart +++ b/packages/flutter/test/material/material_test.dart @@ -924,6 +924,7 @@ void main() { final Key painterKey = UniqueKey(); await tester.pumpWidget(MaterialApp( + theme: ThemeData(useMaterial3: false), home: Scaffold( body: RepaintBoundary( key: painterKey, @@ -962,6 +963,7 @@ void main() { final Key painterKey = UniqueKey(); await tester.pumpWidget(MaterialApp( + theme: ThemeData(useMaterial3: false), home: Scaffold( body: RepaintBoundary( key: painterKey, diff --git a/packages/flutter/test/material/page_test.dart b/packages/flutter/test/material/page_test.dart index 531025084eaf..b0486a9cfac8 100644 --- a/packages/flutter/test/material/page_test.dart +++ b/packages/flutter/test/material/page_test.dart @@ -252,6 +252,7 @@ void main() { RepaintBoundary( key: key, child: MaterialApp( + theme: ThemeData(useMaterial3: false), onGenerateRoute: (RouteSettings settings) { return MaterialPageRoute( builder: (BuildContext context) { diff --git a/packages/flutter/test/material/progress_indicator_test.dart b/packages/flutter/test/material/progress_indicator_test.dart index fdf268f4aa95..c68e3507a897 100644 --- a/packages/flutter/test/material/progress_indicator_test.dart +++ b/packages/flutter/test/material/progress_indicator_test.dart @@ -723,7 +723,10 @@ void main() { final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(50, 50)); await tester.pumpFrames(animationSheet.record( - const _RefreshProgressIndicatorGolden(), + Theme( + data: ThemeData(useMaterial3: false), + child: const _RefreshProgressIndicatorGolden() + ), ), const Duration(seconds: 3)); await expectLater( @@ -1001,11 +1004,14 @@ void main() { final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(40, 40)); await tester.pumpFrames(animationSheet.record( - const Directionality( - textDirection: TextDirection.ltr, - child: Padding( - padding: EdgeInsets.all(4), - child: CircularProgressIndicator(), + Theme( + data: ThemeData(useMaterial3: false), + child: const Directionality( + textDirection: TextDirection.ltr, + child: Padding( + padding: EdgeInsets.all(4), + child: CircularProgressIndicator(), + ), ), ), ), const Duration(seconds: 2)); diff --git a/packages/flutter/test/material/radio_list_tile_test.dart b/packages/flutter/test/material/radio_list_tile_test.dart index f94c18cb5f8e..e5ca1bf498ab 100644 --- a/packages/flutter/test/material/radio_list_tile_test.dart +++ b/packages/flutter/test/material/radio_list_tile_test.dart @@ -1101,7 +1101,7 @@ void main() { return null; } - final ThemeData theme = ThemeData(); + final ThemeData theme = ThemeData(useMaterial3: false); final bool material3 = theme.useMaterial3; Widget buildRadio({bool active = false, bool useOverlay = true}) { return wrap( diff --git a/packages/flutter/test/material/snack_bar_test.dart b/packages/flutter/test/material/snack_bar_test.dart index 23497a23afc7..a31753412f84 100644 --- a/packages/flutter/test/material/snack_bar_test.dart +++ b/packages/flutter/test/material/snack_bar_test.dart @@ -2155,8 +2155,9 @@ void main() { }); testWidgets('SnackBars should be shown above the bottomSheet', (WidgetTester tester) async { - await tester.pumpWidget(const MaterialApp( - home: Scaffold( + await tester.pumpWidget(MaterialApp( + theme: ThemeData(useMaterial3: false), + home: const Scaffold( bottomSheet: SizedBox( width: 200, height: 50, @@ -2238,6 +2239,7 @@ void main() { testWidgets('ScaffoldMessenger presents SnackBars to only the root Scaffold when Scaffolds are nested.', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp( + theme: ThemeData(useMaterial3: false), home: Scaffold( body: const Scaffold(), floatingActionButton: FloatingActionButton(onPressed: () {}), @@ -2439,6 +2441,7 @@ void main() { testWidgets('Snackbar by default clips BackdropFilter', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/98205 await tester.pumpWidget(MaterialApp( + theme: ThemeData(useMaterial3: false), home: Scaffold( body: const Scaffold(), floatingActionButton: FloatingActionButton(onPressed: () {}), @@ -2469,8 +2472,9 @@ void main() { }); testWidgets('Floating snackbar can display optional icon', (WidgetTester tester) async { - await tester.pumpWidget(const MaterialApp( - home: Scaffold( + await tester.pumpWidget(MaterialApp( + theme: ThemeData(useMaterial3: false), + home: const Scaffold( bottomSheet: SizedBox( width: 200, height: 50, @@ -2500,8 +2504,9 @@ void main() { }); testWidgets('Fixed width snackbar can display optional icon', (WidgetTester tester) async { - await tester.pumpWidget(const MaterialApp( - home: Scaffold( + await tester.pumpWidget(MaterialApp( + theme: ThemeData(useMaterial3: false), + home: const Scaffold( bottomSheet: SizedBox( width: 200, height: 50, @@ -2526,8 +2531,9 @@ void main() { }); testWidgets('Fixed snackbar can display optional icon without action', (WidgetTester tester) async { - await tester.pumpWidget(const MaterialApp( - home: Scaffold( + await tester.pumpWidget(MaterialApp( + theme: ThemeData(useMaterial3: false), + home: const Scaffold( bottomSheet: SizedBox( width: 200, height: 50, @@ -2554,8 +2560,9 @@ void main() { testWidgets( 'Floating width snackbar can display optional icon without action', (WidgetTester tester) async { - await tester.pumpWidget(const MaterialApp( - home: Scaffold( + await tester.pumpWidget(MaterialApp( + theme: ThemeData(useMaterial3: false), + home: const Scaffold( bottomSheet: SizedBox( width: 200, height: 50, @@ -2580,8 +2587,9 @@ void main() { }); testWidgets('Floating multi-line snackbar with icon is aligned correctly', (WidgetTester tester) async { - await tester.pumpWidget(const MaterialApp( - home: Scaffold( + await tester.pumpWidget(MaterialApp( + theme: ThemeData(useMaterial3: false), + home: const Scaffold( bottomSheet: SizedBox( width: 200, height: 50, @@ -2607,8 +2615,9 @@ void main() { }); testWidgets('Floating multi-line snackbar with icon and actionOverflowThreshold=1 is aligned correctly', (WidgetTester tester) async { - await tester.pumpWidget(const MaterialApp( - home: Scaffold( + await tester.pumpWidget(MaterialApp( + theme: ThemeData(useMaterial3: false), + home: const Scaffold( bottomSheet: SizedBox( width: 200, height: 50, @@ -2627,10 +2636,10 @@ void main() { behavior: SnackBarBehavior.floating, actionOverflowThreshold: 1, )); - await tester.pumpAndSettle(); // Have the SnackBar fully animate out. + await tester.pumpAndSettle(); // Have the SnackBar fully animate in. await expectLater(find.byType(MaterialApp), - matchesGoldenFile('snack_bar.goldenTest.multiLineWithIconWithZeroActionOverflowThreshold.png')); + matchesGoldenFile('snack_bar.goldenTest.multiLineWithIconWithZeroActionOverflowThreshold.png')); }); testWidgets( diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index 687fda4c4f5d..08026d59b4c2 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -918,13 +918,16 @@ void main() { }); testWidgets('Material cursor golden', (WidgetTester tester) async { - final Widget widget = overlay( - child: const RepaintBoundary( - key: ValueKey(1), - child: TextField( - cursorColor: Colors.blue, - cursorWidth: 15, - cursorRadius: Radius.circular(3.0), + final Widget widget = Theme( + data: ThemeData(useMaterial3: false), + child: overlay( + child: const RepaintBoundary( + key: ValueKey(1), + child: TextField( + cursorColor: Colors.blue, + cursorWidth: 15, + cursorRadius: Radius.circular(3.0), + ), ), ), ); @@ -1095,6 +1098,7 @@ void main() { ); await tester.pumpWidget( MaterialApp( + theme: ThemeData(useMaterial3: false), home: Material( child: Center( child: RepaintBoundary( @@ -1143,6 +1147,7 @@ void main() { ); await tester.pumpWidget( MaterialApp( + theme: ThemeData(useMaterial3: false), home: Material( child: Center( child: RepaintBoundary(