loadTheme method
override
Asynchronously load the theme data.
This method returns a Future
that when complete will produce a
tuple of ZetaThemeData
, ThemeMode
, and ZetaContrast
.
ZetaThemeData
describes the colors that are used by a theme.
ThemeMode
determines the brightness of the system.
ZetaContrast
defines different contrast styles to use across the application.
Returns a Future ZetaThemeServiceData.
Implementation
@override
Future<ZetaThemeServiceData> loadTheme() async {
final preferences = await SharedPreferences.getInstance();
final modeString = preferences.getString(_kThemeMode);
final themeMode = modeString == ThemeMode.light.name
? ThemeMode.light
: modeString == ThemeMode.dark.name
? ThemeMode.dark
: ThemeMode.system;
final contrastString = preferences.getString(_kContrast);
final contrast = contrastString == ZetaContrast.aaa.name ? ZetaContrast.aaa : ZetaContrast.aa;
final themeId = preferences.getString(_kThemeId);
final fontFamily = preferences.getString(_kFontFamily);
return ZetaThemeServiceData(
themeMode: themeMode,
contrast: contrast,
themeId: themeId,
fontFamily: fontFamily,
);
}