operator == method

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

Returns true if this Byte equals the specified object.

Two Byte objects are equal if they contain the same sequence of bytes.

Example:

final a = Byte(42);
final b = Byte(42);
final c = Byte.fromList([1, 2, 3]);
final d = Byte.fromList([1, 2, 3]);

print(a == b);  // true
print(c == d);  // true
print(a == c);  // false

Implementation

@override
bool operator ==(Object other) {
  if (identical(this, other)) return true;
  if (other is! Byte) return false;

  if (_bytes.length != other._bytes.length) return false;

  for (int i = 0; i < _bytes.length; i++) {
    if (_bytes[i] != other._bytes[i]) return false;
  }

  return true;
}