isEqualTo method Null safety

  1. @nonVirtual
bool isEqualTo(
  1. Parser other,
  2. [Set<Parser>? seen]
)

Recursively tests for structural equality of two parsers.

The code automatically deals with recursive parsers and parsers that refer to other parsers. Do not override this method, instead customize Parser.hasEqualProperties and Parser.children.

Implementation

@nonVirtual
bool isEqualTo(Parser other, [Set<Parser>? seen]) {
  if (this == other) {
    return true;
  }
  if (runtimeType != other.runtimeType || !hasEqualProperties(other)) {
    return false;
  }
  seen ??= {};
  return !seen.add(this) || hasEqualChildren(other, seen);
}