changeUI method
Explicitly change to a particular interface.
Implementation
bool changeUI(String? ui) {
// Allow to chang the interface in the first place.
bool change = _allowChangeUI;
if (change) {
// The parameter may be null
change = ui != null && ui.isNotEmpty;
}
if (change) {
ui = ui!.trim();
// Must be a recognized interface design
change = ui == 'Material' || ui == 'Cupertino';
}
if (change) {
//
if (UniversalPlatform.isMobile) {
if (ui == 'Material') {
_useMaterial = true;
_useCupertino = false;
_switchUI = !UniversalPlatform.isAndroid;
} else {
_useMaterial = false;
_useCupertino = true;
_switchUI = UniversalPlatform.isAndroid;
}
} else {
if (ui == 'Material') {
_useMaterial = true;
_useCupertino = false;
_switchUI = false;
} else {
_useMaterial = false;
_useCupertino = true;
_switchUI = true;
}
}
Prefs.setBool('switchUI', _switchUI);
// Reload the whole App so it works in testing
hotReload(); // because of WidgetsApp(key: GlobalObjectKey(this),
}
return change;
}