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