exists method

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

Check if key exists in local storage

Implementation

@override
/// Check if key exists in local storage
Future<bool> exists(String key) async {
  try {
    final db = await _initDB();
    final transaction = db.transaction(storeName, 'readonly');
    final store = transaction.objectStore(storeName);

    final data = await store.getObject(key);

    if (data == null) {
      return false;
    } else {
      return true;
    }
  } on Exception catch (e) {
    debugPrint(e.toString());
    return false;
  }
}