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:
@@ -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(() {
|
||||
|
||||
Reference in New Issue
Block a user