diff --git a/material_3_demo/lib/color_palettes_screen.dart b/material_3_demo/lib/color_palettes_screen.dart index 580678be7..b1fb16221 100644 --- a/material_3_demo/lib/color_palettes_screen.dart +++ b/material_3_demo/lib/color_palettes_screen.dart @@ -357,15 +357,11 @@ class ColorChip extends StatelessWidget { final Color? onColor; final String label; - static Color contrastColor(Color color) { - final brightness = ThemeData.estimateBrightnessForColor(color); - switch (brightness) { - case Brightness.dark: - return Colors.white; - case Brightness.light: - return Colors.black; - } - } + static Color contrastColor(Color color) => + switch (ThemeData.estimateBrightnessForColor(color)) { + Brightness.dark => Colors.white, + Brightness.light => Colors.black + }; @override Widget build(BuildContext context) { diff --git a/material_3_demo/lib/home.dart b/material_3_demo/lib/home.dart index 4bb4621b8..5d2ef5eda 100644 --- a/material_3_demo/lib/home.dart +++ b/material_3_demo/lib/home.dart @@ -108,29 +108,26 @@ class _HomeState extends State with SingleTickerProviderStateMixin { } Widget createScreenFor( - ScreenSelected screenSelected, bool showNavBarExample) { - switch (screenSelected) { - case ScreenSelected.component: - return Expanded( - child: OneTwoTransition( - animation: railAnimation, - one: FirstComponentList( - showNavBottomBar: showNavBarExample, + ScreenSelected screenSelected, + bool showNavBarExample, + ) => + switch (screenSelected) { + ScreenSelected.component => Expanded( + child: OneTwoTransition( + animation: railAnimation, + one: FirstComponentList( + showNavBottomBar: showNavBarExample, + scaffoldKey: scaffoldKey, + showSecondList: showMediumSizeLayout || showLargeSizeLayout), + two: SecondComponentList( scaffoldKey: scaffoldKey, - showSecondList: showMediumSizeLayout || showLargeSizeLayout), - two: SecondComponentList( - scaffoldKey: scaffoldKey, + ), ), ), - ); - case ScreenSelected.color: - return const ColorPalettesScreen(); - case ScreenSelected.typography: - return const TypographyScreen(); - case ScreenSelected.elevation: - return const ElevationScreen(); - } - } + ScreenSelected.color => const ColorPalettesScreen(), + ScreenSelected.typography => const TypographyScreen(), + ScreenSelected.elevation => const ElevationScreen() + }; PreferredSizeWidget createAppBar() { return AppBar( diff --git a/material_3_demo/lib/main.dart b/material_3_demo/lib/main.dart index 30426c56e..dab403615 100644 --- a/material_3_demo/lib/main.dart +++ b/material_3_demo/lib/main.dart @@ -47,17 +47,13 @@ class _AppState extends State { ColorScheme? imageColorScheme = const ColorScheme.light(); ColorSelectionMethod colorSelectionMethod = ColorSelectionMethod.colorSeed; - bool get useLightMode { - switch (themeMode) { - case ThemeMode.system: - return View.of(context).platformDispatcher.platformBrightness == - Brightness.light; - case ThemeMode.light: - return true; - case ThemeMode.dark: - return false; - } - } + bool get useLightMode => switch (themeMode) { + ThemeMode.system => + View.of(context).platformDispatcher.platformBrightness == + Brightness.light, + ThemeMode.light => true, + ThemeMode.dark => false + }; void handleBrightnessChange(bool useLightMode) { setState(() {