Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: EquatableMixin == to use Object instead of Object? #122

Merged
merged 1 commit into from Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/equatable_mixin.dart
Expand Up @@ -16,7 +16,7 @@ mixin EquatableMixin {
bool? get stringify => null;

@override
bool operator ==(Object? other) {
bool operator ==(Object other) {
return identical(this, other) ||
other is EquatableMixin &&
runtimeType == other.runtimeType &&
Expand Down
43 changes: 0 additions & 43 deletions test/equatable_mixin_test.dart
Expand Up @@ -122,32 +122,6 @@ class IterableWithFlag<T> extends Iterable<T> with EquatableMixin {
Iterator<T> get iterator => list.iterator;
}

class LegacyEqualityOverride {
const LegacyEqualityOverride(this.x);

final int x;

@override
bool operator ==(dynamic o) {
if (identical(this, o)) return true;

return o is LegacyEqualityOverride && o.x == x;
}

@override
int get hashCode => x.hashCode;
}

class LegacyEqualityOverrideEquatable extends LegacyEqualityOverride
with EquatableMixin {
LegacyEqualityOverrideEquatable(int x, this.y) : super(x);

final int y;

@override
List<Object?> get props => [x, y];
}

void main() {
late bool globalStringify;

Expand Down Expand Up @@ -701,21 +675,4 @@ void main() {
expect(instanceA == instanceB, isFalse);
});
});

group('LegacyEqualityOverride', () {
test('should be equal when different instances have same values', () {
final instanceA = LegacyEqualityOverrideEquatable(0, 1);
final instanceB = LegacyEqualityOverrideEquatable(0, 1);

expect(instanceA == instanceB, isTrue);
});

test('should not be equal when different instances have different values',
() {
final instanceA = LegacyEqualityOverrideEquatable(0, 0);
final instanceB = LegacyEqualityOverrideEquatable(0, 1);

expect(instanceA == instanceB, isFalse);
});
});
}