getCachedResponse static method

Future<HttpResponse?> getCachedResponse({
  1. required String cacheKey,
  2. required bool forceUpdate,
})

Retrieves cached response if available and valid. Returns null on cache miss or when forceUpdate is true.

Implementation

static Future<HttpResponse<dynamic>?> getCachedResponse({
  required String cacheKey,
  required bool forceUpdate,
}) async {
  if (forceUpdate) {
    return null;
  }

  final cachedResponse = await HiveService.getCachedResponse(cacheKey);
  if (cachedResponse != null) {
    debugPrint('----HttpService: Using cached response-----');
  }
  return cachedResponse;
}