addItem method Null safety

Future addItem(
  1. DatabaseItem item
)

Adds an item to the database

If another item is present with the same id it will be replaced.

Implementation

Future addItem(DatabaseItem item) async {
  await ensureDbOpen();
  // Add table to the database if not currently present
  final tableName = item.tableName;
  if (!tableNames.contains(tableName)) {
    await addTable(tableName, item: item);
  }

  await verifySchema(item);

  await db.insert(
    tableName,
    item.toMap(),
    conflictAlgorithm: ConflictAlgorithm.replace,
  );
}