Skip to content

Latest commit

History

History
29 lines (17 loc) 路 1004 Bytes

File metadata and controls

29 lines (17 loc) 路 1004 Bytes

Record Equality in Dart 3

Did you know?

In Dart, two records are considered equal if they have:

  • the same fields (named and positional)
  • the same values for each field

This makes them a good lightweight alternative to classes when you need to return multiple values (and potentially compare them).


On the other hand, two distinct instances of the same class will NOT be considered equal, even if they have the SAME values, UNLESS we've implemented the == operator.

P.S. Don't overuse records: classes are still the way to go if you need to store data AND functionality. 馃憤


Found this useful? Show some love and share the original tweet 馃檹


Previous Next
MediaQuery as InheritedModel Getting a Future from a FutureProvider with Riverpod