getMissingFieldsInCopyWith function

Set<String> getMissingFieldsInCopyWith(
  1. ClassDeclaration classDecl,
  2. MethodDeclaration copyWithMethod
)

Returns the set of fields that are missing from an existing copyWith method

Implementation

Set<String> getMissingFieldsInCopyWith(
  ClassDeclaration classDecl,
  MethodDeclaration copyWithMethod,
) {
  final classFieldNames = getClassFields(
    classDecl,
    constructorOnly: true,
  ).map((field) => field.name);

  final copyWithParams = getCopyWithParameters(copyWithMethod);

  return classFieldNames
      .where((field) => !copyWithParams.contains(field))
      .toSet();
}