insert static method

Future<Exception?> insert(
  1. String table,
  2. String key,
  3. Map<String, dynamic> map, {
  4. bool logExceptions = true,
})

Implementation

static Future<Exception?> insert(String table, String key, Map<String, dynamic> map,
    {bool logExceptions = true}) async {
  Exception? exception;
  try {
    if (!initialized) return null;
    var box = await Hive.openBox(table);
    await box.put(key, map);
  } on Exception catch (e) {
    // log calling insert causes an infinite loop on error
    // we pass logExceptions=false to prevent this
    if (logExceptions) {
      Log().error('Error Inserting Record Key [$key] into Table [$table]');
      Log().exception(e,
          caller:
              'Future<Exception?> insert(String table, dynamic key, dynamic record) async');
    }
    exception = e;
  }
  return exception;
}