Created
July 5, 2022 07:05
-
-
Save nbnD/97e0c4ce6f8c41a2c20affb5287cb440 to your computer and use it in GitHub Desktop.
Theme Switcher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:shared_preferences/shared_preferences.dart'; | |
class MyThemePreferences { | |
static const THEME_KEY = "theme_key"; | |
setTheme(bool value) async { | |
SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); | |
sharedPreferences.setBool(THEME_KEY, value); | |
} | |
getTheme() async { | |
SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); | |
return sharedPreferences.getBool(THEME_KEY) ?? false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment