operator == method

  1. @override
bool operator ==(
  1. Object other
)
override

Returns true if this version is equal to other.

other may be a ComparableVersion or a String representing the same version number. Returns false for any other type, and also returns false (rather than throwing) when other is a String that cannot be parsed as a valid major.minor.patch version — this keeps operator == stable and consistent with Dart's equality contract.

Implementation

@override
bool operator ==(Object other) {
  if (other is ComparableVersion) {
    return compareTo(other) == 0;
  }
  if (other is String) {
    try {
      return compareTo(ComparableVersion(other)) == 0;
    } on FormatException {
      return false;
    }
  }
  return false;
}