switchTheme method

void switchTheme({
  1. Brightness? brightness,
  2. MaterialColor? color,
  3. bool isInit = false,
  4. bool forciblyModify = false,
})

切换指定色彩 没有传brightness就不改变brightness,color同理 forciblyModify强制修改 用于初始化的时候没有适配文字大小的问题

Implementation

void switchTheme(
    {Brightness? brightness,
    MaterialColor? color,
    bool isInit = false,
    bool forciblyModify = false}) {
  if (forciblyModify &&
      brightness == _brightness &&
      (color == null || _themeColor == color)) return;
  _brightness = brightness ?? _brightness;
  _themeColor = color ?? _themeColor;
  _themeData = _generateThemeData(_brightness,
      themeColor: _themeColor, modifyGlobal: true);
  if (isInit) return;
  delayed(() => notifyListeners());
  saveTheme2Storage(_brightness, _themeColor);
}