getData method

dynamic getData(
  1. String key
)

Implementation

dynamic getData(String key) {
  final box = Hive.box(_cacheBox);
  final cache = box.get(key);

  if (cache != null) {
    final expiry = cache["expiry"];
    if (DateTime.now().millisecondsSinceEpoch < expiry) {
      return cache["data"];
    } else {
      box.delete(key); // Remove expired cache
    }
  }
  return null;
}