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

Override object equality operator and hashcode #317

Merged
merged 9 commits into from
Jul 16, 2023

Conversation

Lohann
Copy link
Collaborator

@Lohann Lohann commented Jul 15, 2023

This PR overrides the operator == and hashCode method of generated files, this is a common practice in dart in order to be able to compare different objects but with same attributes.

example:

class A {
  final int value;
  
  @override
  bool operator ==(Object other) =>
      identical(this, other) || other is A && other.value == value;

  @override
  int get hashCode => Object.hash(value);
}

class B {
  final BigInt valueA;
  final A valueB;
  
  @override
  bool operator ==(Object other) =>
      identical(this, other) || other is B && other.valueA == valueA && other.valueB == valueB;

  @override
  int get hashCode => Object.hash(valueA, valueB);
}

@Lohann Lohann merged commit 17302d2 into main Jul 16, 2023
6 checks passed
@Lohann Lohann deleted the feature/support-object-comparison branch July 16, 2023 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant