From ebc2c3e437eef6006f77a3e7a78557c8f3ec3f19 Mon Sep 17 00:00:00 2001 From: Taha Tesser Date: Tue, 10 Sep 2024 19:27:14 +0300 Subject: [PATCH] Clean up `SnackBar` inherit theme data test (#154921) Fixes [Verbose `SnackBar` inherit theme data test](https://github.com/flutter/flutter/issues/154920) --- .../flutter/test/material/snack_bar_test.dart | 90 ++----------------- 1 file changed, 6 insertions(+), 84 deletions(-) diff --git a/packages/flutter/test/material/snack_bar_test.dart b/packages/flutter/test/material/snack_bar_test.dart index 4c7c13a9f38..d76a59e7b34 100644 --- a/packages/flutter/test/material/snack_bar_test.dart +++ b/packages/flutter/test/material/snack_bar_test.dart @@ -596,90 +596,13 @@ void main() { expect(buttonTextStyle.color, equals(darkTheme.colorScheme.inversePrimary)); }); - testWidgets('SnackBar should inherit theme data from its ancestor.', (WidgetTester tester) async { - final SliderThemeData sliderTheme = SliderThemeData.fromPrimaryColors( - primaryColor: Colors.black, - primaryColorDark: Colors.black, - primaryColorLight: Colors.black, - valueIndicatorTextStyle: const TextStyle(color: Colors.black), + testWidgets('SnackBar should inherit theme data from its ancestor', (WidgetTester tester) async { + final ThemeData theme = ThemeData( + colorScheme: ColorScheme.fromSeed( + seedColor: Colors.green, + brightness: Brightness.dark, + ), ); - - final ChipThemeData chipTheme = ChipThemeData.fromDefaults( - primaryColor: Colors.black, - secondaryColor: Colors.white, - labelStyle: const TextStyle(color: Colors.black), - ); - - const PageTransitionsTheme pageTransitionTheme = PageTransitionsTheme( - builders: { - TargetPlatform.iOS: CupertinoPageTransitionsBuilder(), - TargetPlatform.macOS: CupertinoPageTransitionsBuilder(), - }, - ); - - final ThemeData theme = ThemeData.light().copyWith( - visualDensity: VisualDensity.standard, - primaryColor: Colors.black, - primaryColorLight: Colors.black, - primaryColorDark: Colors.black, - canvasColor: Colors.black, - shadowColor: Colors.black, - scaffoldBackgroundColor: Colors.black, - cardColor: Colors.black, - dividerColor: Colors.black, - focusColor: Colors.black, - hoverColor: Colors.black, - highlightColor: Colors.black, - splashColor: Colors.black, - splashFactory: InkRipple.splashFactory, - unselectedWidgetColor: Colors.black, - disabledColor: Colors.black, - buttonTheme: const ButtonThemeData(colorScheme: ColorScheme.dark()), - toggleButtonsTheme: const ToggleButtonsThemeData(textStyle: TextStyle(color: Colors.black)), - secondaryHeaderColor: Colors.black, - dialogBackgroundColor: Colors.black, - indicatorColor: Colors.black, - hintColor: Colors.black, - textTheme: ThemeData.dark().textTheme, - primaryTextTheme: ThemeData.dark().textTheme, - inputDecorationTheme: ThemeData.dark().inputDecorationTheme.copyWith(border: const OutlineInputBorder()), - iconTheme: ThemeData.dark().iconTheme, - primaryIconTheme: ThemeData.dark().iconTheme, - sliderTheme: sliderTheme, - tabBarTheme: const TabBarTheme(labelColor: Colors.black), - tooltipTheme: const TooltipThemeData(height: 100), - cardTheme: const CardTheme(color: Colors.black), - chipTheme: chipTheme, - platform: TargetPlatform.iOS, - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - applyElevationOverlayColor: false, - pageTransitionsTheme: pageTransitionTheme, - appBarTheme: const AppBarTheme(backgroundColor: Colors.black), - scrollbarTheme: const ScrollbarThemeData(radius: Radius.circular(10.0)), - bottomAppBarTheme: const BottomAppBarTheme(color: Colors.black), - colorScheme: const ColorScheme.light(), - dialogTheme: const DialogTheme(backgroundColor: Colors.black), - floatingActionButtonTheme: const FloatingActionButtonThemeData(backgroundColor: Colors.black), - navigationRailTheme: const NavigationRailThemeData(backgroundColor: Colors.black), - typography: Typography.material2018(), - snackBarTheme: const SnackBarThemeData(backgroundColor: Colors.black), - bottomSheetTheme: const BottomSheetThemeData(backgroundColor: Colors.black), - popupMenuTheme: const PopupMenuThemeData(color: Colors.black), - bannerTheme: const MaterialBannerThemeData(backgroundColor: Colors.black), - dividerTheme: const DividerThemeData(color: Colors.black), - bottomNavigationBarTheme: const BottomNavigationBarThemeData(type: BottomNavigationBarType.fixed), - timePickerTheme: const TimePickerThemeData(backgroundColor: Colors.black), - textButtonTheme: TextButtonThemeData(style: TextButton.styleFrom(foregroundColor: Colors.red)), - elevatedButtonTheme: ElevatedButtonThemeData(style: ElevatedButton.styleFrom(backgroundColor: Colors.green)), - outlinedButtonTheme: OutlinedButtonThemeData(style: OutlinedButton.styleFrom(foregroundColor: Colors.blue)), - textSelectionTheme: const TextSelectionThemeData(cursorColor: Colors.black), - dataTableTheme: const DataTableThemeData(), - checkboxTheme: const CheckboxThemeData(), - radioTheme: const RadioThemeData(), - switchTheme: const SwitchThemeData(), - progressIndicatorTheme: const ProgressIndicatorThemeData(), - ); - ThemeData? themeBeforeSnackBar; ThemeData? themeAfterSnackBar; await tester.pumpWidget( @@ -722,7 +645,6 @@ void main() { final ThemeData comparedTheme = themeBeforeSnackBar!.copyWith( colorScheme: themeAfterSnackBar!.colorScheme, ); // Fields replaced by SnackBar. - expect(comparedTheme, themeAfterSnackBar); });