I'm trying to clear the Firebase Cache after a user logs out from the app. I've already tried this but the code clears all my files it seems because I had background images before logging out and all those images disappeared after logging out.
void clearCache() async{
var appDir = (await getTemporaryDirectory()).path;
new Directory(appDir).delete(recursive: true); }
This is not the effect I want. I merely just want to clear the Firebase Cache and retain the rest of my app files. How would I go about achieving this ?
Here are the logout code snippets
new FlatButton(
child: new Text("Yes",style: new TextStyle(fontFamily: 'DroidSansChinese', color: Colors.white),),
onPressed: () {_signOut(); clearPreferences();clearCache();},
),
void _signOut() async {
await _auth.signOut();
Navigator.of(context)
.pushAndRemoveUntil(MaterialPageRoute(builder: (context) => LoginPage()), (Route<dynamic> route) => false);
}
void clearPreferences() async{
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString('name', '');
await prefs.setString('surname', '');
await prefs.setString('email', '');
await prefs.setString('id', '');
print(prefs.getString('name'));
}
void clearCache() async{
var appDir = (await getTemporaryDirectory()).path;
new Directory(appDir).delete(recursive: true);
}