getConflicts static method

List<String> getConflicts(
  1. List<Skill> skills
)

Get list of conflicting names from a list of skills

Returns a list of names that appear more than once in the skills list. Useful for providing detailed conflict information to users.

Args: skills: List of skills to check for conflicts

Returns: List of conflicting skill names

Throws: ArgumentError: If skills list is null or contains null values

Implementation

static List<String> getConflicts(List<Skill> skills) {
  // In Dart's null safety, skills cannot be null and cannot contain null values
  // All skills are guaranteed to be non-null by the type system

  final seen = <String>{};
  final conflicts = <String>[];

  for (final skill in skills) {
    if (seen.contains(skill.name)) {
      if (!conflicts.contains(skill.name)) {
        conflicts.add(skill.name);
      }
    } else {
      seen.add(skill.name);
    }
  }

  return conflicts;
}