operator == method
Determines whether this field is equal to another object.
Two fields are considered equal if:
- They are the same instance (identical), OR
- The other object is of type
Tand equals this field's rawValue, OR - The other object is a JsonField<T> with the same fieldName and rawValue
Parameters:
other: The object to compare with this field.
Returns:
true if the objects are equal according to the criteria above, false otherwise.
Example:
final field1 = JsonString('name')..value = 'John';
final field2 = JsonString('name')..value = 'John';
print(field1 == field2); // true
print(field1 == 'John'); // true (compares with rawValue)
Implementation
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
if (other is T) {
return other == rawValue;
}
return other is JsonField<T> &&
other.fieldName == fieldName &&
other.rawValue == rawValue;
}