storeWithKey method

Future<void> storeWithKey(
  1. String key,
  2. dynamic obj
)

Store a object with the key. The obj must be one of bool, double, int, String or List

Implementation

Future<void> storeWithKey(String key, dynamic obj) async {
  if (obj == null) {
    return;
  }
  final savedKey = 'ume_${runtimeType.toString}_$key';
  final SharedPreferences prefs = await _sharedPref;
  if (obj is bool) {
    await prefs.setBool(savedKey, obj);
  } else if (obj is double) {
    await prefs.setDouble(savedKey, obj);
  } else if (obj is int) {
    await prefs.setInt(savedKey, obj);
  } else if (obj is String) {
    await prefs.setString(savedKey, obj);
  } else if (obj is List<String>) {
    await prefs.setStringList(savedKey, obj);
  }
}