如何实现 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/