operator == method

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

Compare slugid to other slugid.

This method also accepts string representations of slugids and UUIDs.

Implementation

@override
bool operator ==(Object other) {
  // If other is a string we try to decode it.
  if (other is String) {
    try {
      other = Slugid(other);
    } on ArgumentError {
      return false;
    }
  }
  // If other is a slugid, we compare bytes.
  if (other is Slugid) {
    for (var i = 0; i < _bytes.length; i++) {
      if (_bytes[i] != other._bytes[i]) {
        return false;
      }
    }
    return true;
  }
  return false;
}