Equality in Flutter and Dart with Equatable
· 3 min read
In this article, we will review how equality works in Dart and Flutter and how the Equatable package can help us to avoid writing a lot of boilerplate code.
We already know that If we want to compare two variables, we can use the ==
operator. For example, if we want to
compare two strings, the code is:
final car1 = "Toyota";
final car2 = "Toyota";
print(car1 == car2); // Result: true
And if we want to compare two numbers, the code is:
final phone1 = 52123456;
final phone2 = 52123456;
print(phone1 == phone2); // Result: true