delete method

  1. @override
void delete(
  1. String id
)
override

Delete.

Implementation

@override
void delete(String id) {
  final record = byId(id);
  if (record == null) {
    throw NmCommandSetRepositoryException('Command set $id not found.');
  }
  if (record.isSystem) {
    throw const NmCommandSetRepositoryException('A system command set cannot be deleted.');
  }
  if (record.usedByPlanIds.isNotEmpty) {
    throw const NmCommandSetRepositoryException('Reassign the plans that use this command set first.');
  }
  _records = _records.where((item) => item.id != id).toList();
}