setField method

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

Updates a given mapping to include a Field.

Implementation

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

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