areMethodsEqual static method
Returns true if two method declarations are structurally equal (including return type, parameters, and body).
Implementation
static bool areMethodsEqual(MethodDeclaration a, MethodDeclaration b) {
if (a.name.lexeme != b.name.lexeme) return false;
if (a.returnType?.toSource() != b.returnType?.toSource()) return false;
if (a.parameters?.parameters.length != b.parameters?.parameters.length) {
return false;
}
final paramsA = a.parameters?.parameters ?? [];
final paramsB = b.parameters?.parameters ?? [];
for (var i = 0; i < paramsA.length; i++) {
if (paramsA[i].toSource() != paramsB[i].toSource()) return false;
}
if (a.body.toSource() != b.body.toSource()) return false;
return true;
}