fromHive method

Future<String?> fromHive(
  1. String? key,
  2. bool refresh
)

Implementation

Future<String?> fromHive(String? key, bool refresh) async {
  // get data from cache
  if ((timetolive > 0) && (!refresh)) {
    // found cached data?
    hive.Data? row = await hive.Data.find(key!);

    // expired?
    bool expired = true;
    if ((row?.expires ?? 0) >= DateTime.now().millisecondsSinceEpoch) {
      expired = false;
    }

    // Return Cached Data
    if (!expired) return row!.value;
  }
  return null;
}