changeUI method

bool changeUI(
  1. String? ui
)

Explicitly change to a particular interface.

Implementation

bool changeUI(String? ui) {
  // The parameter may be null
  var change = ui != null && ui.isNotEmpty;

  if (change) {
    ui = ui.toLowerCase().trim();
    // Must be a recognized interface design
    change = ui == 'material' || ui == 'cupertino';
  }

  if (change) {
    //
    if (_AppState.appObj.inMobile) {
      if (ui == 'material') {
        _useMaterial = true;
        _useCupertino = false;
        _switchUI = !_AppState.appObj.inAndroid;
      } else {
        _useMaterial = false;
        _useCupertino = true;
        _switchUI = _AppState.appObj.inAndroid;
      }
    } else {
      if (ui == 'material') {
        _useMaterial = true;
        _useCupertino = false;
        _switchUI = false;
      } else {
        _useMaterial = false;
        _useCupertino = true;
        _switchUI = true;
      }
    }

    _AppState.appObj.prefs.setBool('switchUI', _switchUI);

    // Reload the whole App so it works in testing
    hotReload(); // because of WidgetsApp(key: GlobalObjectKey(this),
  }
  return change;
}