Persist the chosen theme using Shared Preferences
// _initPref() is to iniliaze the _pref variable
_initPrefs() async {
if(_pref == null)
_pref = await SharedPreferences.getInstance();
}
_loadFromPrefs() async {
await _initPrefs();
_darkTheme = _pref.getBool(key) ?? true;
notifyListeners();
}
_saveToPrefs() async {
await _initPrefs();
_pref.setBool(key, _darkTheme);
}