1
0
mirror of https://github.com/flutter/samples.git synced 2026-05-10 17:07:28 +00:00

[material_3_demo] Use switch expressions (#2193)

This commit is contained in:
Kevin Moore
2024-03-06 11:44:05 -08:00
committed by GitHub
parent e5f3bacaf8
commit 5b6d214d2a
3 changed files with 29 additions and 40 deletions

View File

@@ -47,17 +47,13 @@ class _AppState extends State<App> {
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(() {