save method

Future<void> save(
  1. String key,
  2. dynamic value
)

Implementation

Future<void> save(String key, dynamic value) async{
  SharedPreferences pref = _pref!;
  if(value is double){
    await pref.setDouble(key, value);
  }
  else if(value is int){
    await pref.setInt(key, value);
  }
  else if(value is String){
    await pref.setString(key, value);
  }
  else if(value is List<String>){
    await pref.setStringList(key, value);
  }
  else if(value is bool){
    await pref.setBool(key, value);
  }
  else if(value is NUIEnt){
    await pref.setString(key, jsonEncode(value));
  }
  else{
    throw new Exception("NUISharedPrefUtil -> value type of ${value.runtimeType} is not an acceptable value for shared preference");
  }
}