checkCache method

  1. @override
Future<bool> checkCache(
  1. String key
)
override

check time storage if cached data exists and is valid key - the key used to store the data data - string version of the data to be stored

Implementation

@override
Future<bool> checkCache(String key) async {
  if (!isInitialized) await init();
  var time = _prefs?.getInt('$key-time');
  if (kDebugMode) {
    print(
        'cache: $key, $time, ${_prefs?.getInt('$key-time')} ${DateTime.fromMillisecondsSinceEpoch(time ?? 001)}');
  }
  if (time == null) return false;
  // return
  try {
    return !(time).isPast;
  } catch (e) {
    return false;
  }
}