`Foo(1) == Foo(1.0)` is false
Mike278 opened this issue · comments
class Foo with EquatableMixin {
final num bar;
Foo(this.bar);
@override
List<Object?> get props => [bar];
}
int anInt = 1;
double aDouble = 1.0;
print(anInt == aDouble); // true
print(Foo(anInt) == Foo(aDouble)); // false
I understand why comparing runtimeType
s is useful in general, but I wonder if there should be a special case for num
- especially considering Dart's support for assigning integer literals to doubles.
Making an exception for num could lead to unexpected behavior for users who rely on strict type equality. Can you override the equality check in your own classes to suit your needs?
Agreed with @wednesdei closing for now as this is working as expected.