flutter - 如何实现 Flutter 在注销时清除用户应用程序数据和存储

标签 flutter

如何实现 Flutter App 在注销时清除用户应用程序数据和存储..
我想清除所有内容(共享首选项、全局变量、单例、本地存储、缓存)
这应该相当于 Android > 设置 > 应用程序 > 清除存储和清除缓存..

最佳答案

第一次安装 path_provider

/// this will delete cache
Future<void> _deleteCacheDir() async {
    final cacheDir = await getTemporaryDirectory();

    if (cacheDir.existsSync()) {
      cacheDir.deleteSync(recursive: true);
    }
}

/// this will delete app's storage
Future<void> _deleteAppDir() async {
    final appDir = await getApplicationSupportDirectory();

    if(appDir.existsSync()){
      appDir.deleteSync(recursive: true);
    }
}
见原答案here

关于flutter - 如何实现 Flutter 在注销时清除用户应用程序数据和存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62547759/

相关文章:

android - 缓慢 flutter 的 GridView

dart - dart/flutter 中的这个一元后缀是什么?

flutter - 屏幕应该是无状态的还是有状态的?

flutter 网络 : Overflow issue in bottom

flutter - 如何在 flutter 中的文本字段中填充数据

flutter - Flutter从var中的图像获取像素颜色

android - 为什么当我使用 pushNamedReplacement 而不是 pushReplacement 时它不起作用?

flutter ,如何在图像底部放置按钮?

firebase - “必须为文本小部件提供非空字符串”(Flutter)

flutter - 如何在 Flutter 中反转图像颜色?