king_cache

Creator: coderz1093

Last updated:

Add to Cart

Description:

king cache

🌟 King Cache 🌟
This package is used to cache API results so the next time you call the same API, it will return the cached result instead of calling the API again. This will help reduce the number of api calls and improve your app's user experience.
This package uses a file-based caching system.
It gives you a couple of functions to manage the cache. It also has a log function so you can add, remove, clear and share logs. It also gives you the ability to set the cache expiry time.



































Features #


Cache API results.
Set cache expiry time.
Manage cache.
Log cache.
Clear cache.
Share cache.

Getting started #

Add this package to your pubspec.yaml file.
Import the package.
Call the functions.

Usage #
KingCache.setBaseUrl('https://jsonplaceholder.typicode.com/');
copied to clipboard
KingCache.setHeaders({'Content-Type': 'application/json'});
copied to clipboard
TextButton(
onPressed: () async {
KingCache.storeLog('Call Json Place Holder API');
await KingCache.cacheViaRest(
'https://jsonplaceholder.typicode.com/todos/1',
method: HttpMethod.get,
onSuccess: (data) {
// This will execute 2 times when you have data in data
debugPrint(data);
KingCache.storeLog('Response: $data');
},
onError: (data) => debugPrint(data.message),
apiResponse: (data) => debugPrint(data.message),
isCacheHit: (isHit) => debugPrint('Is Cache Hit: $isHit'),
shouldUpdate: false,
expiryTime: DateTime.now().add(const Duration(hours: 1)),
);
KingCache.storeLog('Call Json Place Holder API');
},
child: const Text('Json Place Holder API'),
),
copied to clipboard
TextButton(
onPressed: () async {
debugPrint(await KingCache.getLog);
},
child: const Text('Get Logs'),
)
copied to clipboard
TextButton(
onPressed: () => KingCache.shareLogs,
child: const Text('Share Logs'),
)
copied to clipboard
TextButton(
onPressed: () => KingCache.clearLog,
child: const Text('Clear Logs'),
)
copied to clipboard
TextButton(
onPressed: () => KingCache.clearAllCache,
child: const Text('Clear All Cache'),
)
copied to clipboard
🧑🏻 Author #
Rohit Jain


🌌 Profile


🏮 Email


🦁 Website


🤝 Support
You can expect responsive replies and fast fixes to any issues that appear.
🎀 Contributions (GitHub Flow), 🔥 issues, and 🥮 feature requests are most welcome!
💙 If you like this project, Give it a ⭐ and Share it with friends!
💰 Donations Links






Made with Flutter & ❤️ in India

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.