如何实现 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);
}
}
Run Code Online (Sandbox Code Playgroud)
在这里查看原始答案
| 归档时间: |
|
| 查看次数: |
1429 次 |
| 最近记录: |