setTheme method
- required bool isDark,
Persists the given isDark
to SharedPreferences as the app's theme.
isDark
is true
if the app should use the dark theme, and false
otherwise.
This function will save the current theme state to the device's SharedPreferences, and is intended to be called whenever the user changes the theme.
Implementation
Future<void> setTheme({required final bool isDark}) async {
final sharedPreferences = await SharedPreferences.getInstance();
await sharedPreferences.setBool(themeKey, isDark);
}