setSystemTheme method
Sets the theme to the system theme, which is either dark or light depending on the device's current brightness setting.
Persists the chosen theme to SharedPreferences.
Emits a new ThemeState with the chosen isDark
and
ThemeMode.system.
Implementation
Future<void> setSystemTheme() async {
final isDark =
PlatformDispatcher.instance.platformBrightness == Brightness.dark;
final newState = state.copyWith(
isDark: isDark,
themeMode: ThemeMode.system,
);
await _persistTheme(newState);
emit(newState);
}