import 'package:localstore/localstore.dart'; import '../api/request_cache.dart'; class DataCleaner { static Future cleanOldCache() async { final cacheData = await Localstore.instance .collection(RequestCache.collection) .get(); cacheData?.forEach((key, value) async { final lastUpdate = DateTime.fromMillisecondsSinceEpoch( value['lastupdate'] as int, ); if (DateTime.now() .subtract(const Duration(days: 200)) .isAfter(lastUpdate)) { await Localstore.instance .collection(RequestCache.collection) .doc(key.split('/').last) .delete(); } }); } }