removeField method

void removeField(
  1. {required AnkiMapping mapping,
  2. required Field field,
  3. required bool isCollapsed}
)

Updates a given mapping to remove a Field.

Implementation

void removeField({
  required AnkiMapping mapping,
  required Field field,
  required bool isCollapsed,
}) async {
  if (isCollapsed) {
    mapping.creatorCollapsedFieldKeys = [
      ...(mapping.creatorCollapsedFieldKeys)
          .whereNot((key) => key == field.uniqueKey)
    ];
  } else {
    mapping.creatorFieldKeys = [
      ...(mapping.creatorFieldKeys).whereNot((key) => key == field.uniqueKey)
    ];
  }

  _database.writeTxnSync(() {
    _database.ankiMappings.putSync(mapping);
  });
}