setTheme method
Persists mode and immediately updates the UI.
Implementation
Future<void> setTheme(ThemeMode mode) async {
state = AsyncData(mode);
final prefs = await ref.read(sharedPreferencesProvider.future);
await prefs.setString(_themeKey, _toString(mode));
}