【问题标题】:How to set null values in SharedPreferences?如何在 SharedPreferences 中设置空值?
【发布时间】:2022-12-04 11:25:29
【问题描述】:

Minimal reproducible code:

void main() async {
  final prefs = await SharedPreferences.getInstance();
  await prefs.setString(\'key\', null); // Error
}

How can I set a null value in shared_preferences


Note: I\'m not looking for workarounds like, instead of null, use an empty string \'\' and then check for it.

  • remove that key and later getString call will return null

标签: flutter dart


【解决方案1】:
【解决方案2】:
猜你喜欢
  • 2011-03-20
  • 1970-01-01
  • 1970-01-01
  • 2015-08-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多