Equals class

Allows you get rid of boring == operator overriding, Ides does the same, but with this annotation hide the so long overing to make your class more cleaner and if you change the class property you have no worries.


@Equals()
class User {
  User(
    this.firstName,
    this.lastName,
    this.email,
    this.phone,
    this.dateOfBirth,
    this.country,
    this.city,
    this.postalCode,
  );

  final String firstName;
  final String lastName;
  final String email;
  final String phone;
  final DateTime dateOfBirth;
  final String country;
  final String city;
  final String postalCode;

  @override
  bool operator ==(Object other) => $equals(other);
}

// Below you'll find the generated result,
// I don't know you, but I don't like to have that stuff in my class.

bool $equals(Object other) =>
  identical(this, other) ||
  other is User &&
  runtimeType == other.runtimeType &&
  firstName == other.firstName &&
  lastName == other.lastName &&
  email == other.email &&
  phone == other.phone &&
  dateOfBirth == other.dateOfBirth &&
  country == other.country &&
  city == other.city &&
  postalCode == other.postalCode;

Constructors

Equals.new({bool ignoreAll = false, List<String>? exclude})
{@marco crow.annotation.equals}
const

Properties

exclude List<String>?
Exclude specific fields by passing there name.
final
hashCode int
The hash code for this object.
no setterinherited
ignoreAll bool
This will ignore all fields and check only if this runtimeType is the same as other runtimeType.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited