Created
August 17, 2017 15:04
-
-
Save mehmetf/8f231cb212e814a7f8d73ab17140a66e to your computer and use it in GitHub Desktop.
Implementing cache control on Flutter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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