find static method

Future<Map<String, dynamic>?> find(
  1. String table,
  2. String key
)

Implementation

static Future<Map<String, dynamic>?> find(String table, String key) async {

  if (!initialized) return null;

  dynamic value;
  try {
    var box = await Hive.openBox(table);
    if (box.containsKey(key)) {
      value = await box.get(key);
    } else {
      Log().debug('Table [$table] does not contain a Key [$key]');
    }
  } catch (e) {
    Log().error('Error Querying Record Key [$key] in Table [$table]');
    Log().exception(e,
        caller: 'Future<dynamic> find(String $table, dynamic $key) async');
  }

  // convert to Map<String, dynamic>
  if (value is Map) return value.cast<String, dynamic>();

  // legacy value
  if (value != null) await delete(table, key);

  return null;
}