Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is different between Equatable and Freezed in flutter?

Tags:

flutter

Hi I'm new to flutter and I was following some youtube tutorials and I got wonder what is different between Equatable and Freezed in flutter? I mean purpose of using it is same but I just want to know in which case we better use Equatable or Freezed.

like image 445
jenny Avatar asked Dec 23 '22 16:12

jenny


1 Answers

I mean purpose of using it is same

Not at all. Equatable is "An abstract class that helps to implement equality without needing to explicitly override == and hashCode.". Freezed is "Code generation for immutable classes that has a simple syntax/API without compromising on the features."

Sure, they both override == and hashCode, but after that, they are very different. Equatable is a mixin to give a consistent, easy == and hashCode (although not necessarily the most efficient). Freezed is a build system that can use annotations to make immutable classes. Definitely different.

like image 179
Randal Schwartz Avatar answered May 21 '23 14:05

Randal Schwartz