getTheme method
Implementation
Future<ThemeType> getTheme() async {
final prefs = await SharedPreferences.getInstance();
// Check if system theme is being used
final useSystemTheme = prefs.getBool(isSystemThemeKey) ?? false;
if (useSystemTheme) {
return ThemeType.system;
}
// Otherwise return saved theme
final themeIndex = prefs.getInt(themeKey);
if (themeIndex != null && ThemeType.values.length > themeIndex) {
return ThemeType.values[themeIndex];
}
return ThemeType.light;
}