HashCode class

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

@HashCode()
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
  int get hashCode => $hashCode();
}

// Below you'll find the generated result.

int $hashCode() =>
  firstName.hashCode ^
  lastName.hashCode ^
  email.hashCode ^
  phone.hashCode ^
  dateOfBirth.hashCode ^
  country.hashCode ^
  city.hashCode ^
  postalCode.hashCode;

Constructors

HashCode.new({List<String>? exclude})
{@marco crow.annotation.hashCode}
const

Properties

exclude List<String>?
Exclude specific fields by passing there name.
final
hashCode int
The hash code for this object.
no setterinherited
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