Skip to content

Instantly share code, notes, and snippets.

@mehmetf
Created August 17, 2017 15:04
Show Gist options
  • Save mehmetf/8f231cb212e814a7f8d73ab17140a66e to your computer and use it in GitHub Desktop.
Save mehmetf/8f231cb212e814a7f8d73ab17140a66e to your computer and use it in GitHub Desktop.
Implementing cache control on Flutter
class CacheControl extends WidgetsBindingObserver {
CacheControl() {
WidgetsBinding.instance.addObserver(this);
}
void _cleanAllCache() {
// Cleans all cache.
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.paused) {
new Future.delayed(
const Duration(minutes: 15),
_cleanAllCache,
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment