resolve method
Resolve naming conflicts between skills
Groups skills by name and resolves conflicts by selecting the first occurrence of each duplicate name. In a full interactive version, this would prompt the user to choose between conflicting skills.
Args: skills: List of skills to resolve conflicts for
Returns: List of skills with conflicts resolved (no duplicate names)
Throws: ArgumentError: If skills list is null or contains null values
Implementation
Future<List<Skill>> resolve(List<Skill> skills) async {
// 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 grouped = <String, List<Skill>>{};
for (final skill in skills) {
grouped.putIfAbsent(skill.name, () => []).add(skill);
}
final resolved = <Skill>[];
for (final entry in grouped.entries) {
if (entry.value.length == 1) {
resolved.add(entry.value.single);
} else {
// Conflict detected - user would need to choose
// For now, take the first one
resolved.add(entry.value.first);
}
}
return resolved;
}