【问题标题】:Does not clear shared preferences?不清除共享偏好?
【发布时间】:2019-05-10 19:59:59
【问题描述】:

试图清除 shared_preferences 并将用户发送到登录屏幕,但似乎没有清除首选项?用户最终出现在登录屏幕上,但下次我运行他们的应用程序时,他们会再次登录,就好像仍然保存了首选项一样。

Future logOutUser(BuildContext context) async {
  SharedPreferences prefs = await SharedPreferences.getInstance();
  await prefs.clear();
  Navigator.pushReplacementNamed(context, '/login');
}

有什么想法吗?

【问题讨论】:

    标签: dart flutter


    【解决方案1】:

    Uuurgh... 已修复。在检查数据时正在寻找 != "",应该是 != null。

    菜鸟错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-29
      • 2019-03-20
      • 1970-01-01
      相关资源
      最近更新 更多