Skip to content

Instantly share code, notes, and snippets.

@yongjhih
Created June 2, 2020 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yongjhih/b47cd0fdea9683eac60c0bf43b4c2e04 to your computer and use it in GitHub Desktop.
Save yongjhih/b47cd0fdea9683eac60c0bf43b4c2e04 to your computer and use it in GitHub Desktop.
extension SharedPreferencesX<T extends SharedPreferences> on T {
bool getBoolOrNull(String key) => as<bool>(get(key));
int getIntOrNull(String key) => as<int>(get(key));
double getDoubleOrNull(String key) => as<double>(get(key));
String getStringOrNull(String key) => as<String>(get(key));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment