Skip to content

Instantly share code, notes, and snippets.

@AliRadwan
Created October 22, 2020 10:00
Show Gist options
  • Save AliRadwan/0e09b8d3156ed2093dddcbec40bc7bde to your computer and use it in GitHub Desktop.
Save AliRadwan/0e09b8d3156ed2093dddcbec40bc7bde to your computer and use it in GitHub Desktop.
this class help to customize you code
import 'package:shared_preferences/shared_preferences.dart';
import 'dart:convert';
//*************** Not working Fine
/// This Class Created by Ali Radwan .
/// it's helping you to save data in local in SharedPreferences.
class SharedPref {
read(String key) async {
final prefs = await SharedPreferences.getInstance();
return json.decode(prefs.getString(key));
}
save(String key, value) async {
final prefs = await SharedPreferences.getInstance();
prefs.setString(key, json.encode(value));
}
remove(String key) async {
final prefs = await SharedPreferences.getInstance();
prefs.remove(key);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment