setCustomTheme method

Future<void> setCustomTheme(
  1. String themeKey
)

切换到自定义主题(比如橙色、绿色) themeKey 由项目自己定义,比如 'orange'、'green'

Implementation

Future<void> setCustomTheme(String themeKey) async {
  if (_customTheme == themeKey) return;
  _customTheme = themeKey;
  // 自定义主题默认用 light 模式(项目可以自己改)
  _themeMode = ThemeMode.light;

  await SharedPreferencesBaseUtils.putString(_kCustomTheme, themeKey);
  await SharedPreferencesBaseUtils.putString(_kThemeMode, _themeMode.name);

  notifyListeners();
}