checkpointRemoved method

void checkpointRemoved({
  1. required String categoryId,
  2. required String checkpointId,
  3. required int pjNr,
  4. required int categoryIndex,
  5. required int checkpointIndex,
})

Implementation

void checkpointRemoved({
  required String categoryId,
  required String checkpointId,
  required int pjNr,
  required int categoryIndex,
  required int checkpointIndex,
}) {
  final coordinateCheckpointKey = checkpointKey(
    pjNr: pjNr,
    categoryIndex: categoryIndex,
    checkpointIndex: checkpointIndex,
  );
  final keys = <String>{coordinateCheckpointKey};
  if (checkpointId.trim().isNotEmpty) {
    keys.add(checkpointId.trim());
  }
  for (final key in keys) {
    _editedCheckpointAtByKey.remove(key);
    _categoryCoordinateByCheckpointKey.remove(key);
    _categoryIdByCheckpointKey.remove(key);
  }

  final currentTotal = _totalCheckpointsByCategoryId[categoryId];
  if (currentTotal != null) {
    _totalCheckpointsByCategoryId[categoryId] =
        currentTotal > 0 ? currentTotal - 1 : 0;
  }
  final categoryCoordinate = _categoryCoordinateById[categoryId] ??
      categoryCoordinateKey(
        pjNr: pjNr,
        categoryIndex: categoryIndex,
      );
  _refreshCategoryEntry(categoryId, categoryCoordinate);
  revision.value++;
}