setThemeMode method
- ThemeMode mode
Persists the given ThemeMode to SharedPreferences.
This function saves the current theme mode to the device's SharedPreferences, allowing the app to remember and restore the user's preferred theme mode (light, dark, or system) upon reopening.
Implementation
Future<void> setThemeMode(final ThemeMode mode) async {
final sharedPreferences = await SharedPreferences.getInstance();
await sharedPreferences.setInt(themeModeKey, mode.index);
}