autoChangeThemeMode method
Implementation
ThemeMode autoChangeThemeMode() {
switch (switchInitialPosition) {
case Alignment.centerLeft:
switchInitialPosition = Alignment.center;
switchLastKnownPosition = Alignment.centerLeft;
break;
case Alignment.center:
if (switchLastKnownPosition == Alignment.centerLeft) {
switchInitialPosition = Alignment.centerRight;
} else {
switchInitialPosition = Alignment.centerLeft;
}
break;
case Alignment.centerRight:
switchInitialPosition = Alignment.center;
switchLastKnownPosition = Alignment.centerRight;
break;
default:
switchInitialPosition = Alignment.center;
switchInitialPosition = Alignment.centerLeft;
break;
}
if (switchInitialPosition == Alignment.centerLeft) {
themeMode = ThemeMode.dark;
}
if (switchInitialPosition == Alignment.center) {
themeMode = ThemeMode.system;
}
if (switchInitialPosition == Alignment.centerRight) {
themeMode = ThemeMode.light;
}
// if (themeMode == ThemeMode.system) {
// themeMode = ThemeMode.dark;
// } else if (themeMode == ThemeMode.dark) {
// themeMode = ThemeMode.light;
// } else if (themeMode == ThemeMode.light) {
// themeMode = ThemeMode.system;
// }
notifyListeners();
return themeMode;
}