{"repo":"felangel/equatable","free":true,"listed":false,"github":"https://github.com/felangel/equatable","clone":"git clone https://github.com/felangel/equatable.git","description":"A Dart package that helps to implement value based equality without needing to explicitly override == and hashCode.","language":"Dart","stars":1086,"topics":["flutter","flutter-package","equality","dart","dartlang","equality-comparison","hashcode","identity"],"license":"MIT","category":"mobile-apps","readme_excerpt":"Simplify Equality Comparisons --- Overview Being able to compare objects in Dart often involves having to override the == operator as well as hashCode . Not only is it verbose and tedious, but failure to do so can lead to inefficient code which does not behave as we expect. By default, == returns true if two objects are the same instance. Let's say we have the following class: We can create instances of Person like so: Later if we try to compare two instances of Person either in our production code or in our tests we will run into a problem. For more information about this, you can check out the official Dart Documentation. In order to be able to compare two instances of Person we need to change our class to override == and hashCode like so: Now if we run the following code again: it will be able to compare different instances of Person . You can see how this can quickly become a hassle when dealing with complex classes. This is where Equatable comes in! What does Equatable do? Equatable overrides == and hashCode for you so you don't have to waste your time writing lots of boilerplate code. There are other packages that will actually generate the boilerplate for you; however, you still have to run the code generation step which is not ideal. With Equatable there is no code generation needed and we can focus more on writing amazing applications and less on mundane tasks. Usage First, we need to do add equatable to the dependencies of the pubspec.yaml Next, we need to install i","default_branch":null,"files":null,"tree":[],"storefront":"/r/felangel","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/felangel/equatable/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}