yeniel / native_shared_preferences

BSD 3-Clause "New" or "Revised" License
7 stars 19 forks source link

Support setString('key', null), setInt('key', null) etc #7

Closed TheoLassonder closed 11 months ago

TheoLassonder commented 3 years ago

It's just so convenient to be able to set a string to null to mean "remove the value". It's also what shared_preferences package does.

Instead of code like:

if (from == null) {
  await prefs.remove('epochFrom');
} else {
  await prefs.setInt('epochFrom', from.millisecondsSinceEpoch);
}

you can write:

await prefs.setInt('epochFrom', from?.millisecondsSinceEpoch);

Best of all, this feature can be added with backwards compatibility.

myselfuser1 commented 1 year ago

This might help https://www.youtube.com/watch?v=WN3g1YZswrA

yeniel commented 11 months ago

Hi! This feature is already supported. I will update the example adding a Reset button to the counter. Thanks! 🙂