getCopyWithMethod function
MethodDeclaration?
getCopyWithMethod(
- ClassDeclaration node
Gets the copyWith method from a class, if it exists
Implementation
MethodDeclaration? getCopyWithMethod(ClassDeclaration node) {
try {
return node.members.whereType<MethodDeclaration>().firstWhere((member) {
final name = member.declaredFragment?.element.name ?? member.name.lexeme;
return name == 'copyWith' && !member.isStatic;
});
} catch (_) {
return null;
}
}