initialize static method
- ThemeStorageAdapter? storageAdapter,
Initializes Themed with optional persistent storage.
Should be called before runApp. If storageAdapter is provided, loads the saved theme and persists future changes.
Implementation
static Future<void> initialize({ThemeStorageAdapter? storageAdapter}) async {
_instance._storageAdapter = storageAdapter;
_instance._themes['light'] = ThemeData.light();
_instance._themes['dark'] = ThemeData.dark();
String? lastTheme;
if (storageAdapter != null) {
lastTheme = await storageAdapter.loadTheme();
}
final theme = _instance._themes[lastTheme] ?? _instance._themes['light']!;
_instance.themeNotifier.value = theme;
_instance._currentThemeName = lastTheme ?? 'light';
}