Exploring Records and Patterns
summary
Dart 3 adds records and pattern matching that create positional/named tuple types, auto-generate equals/hashCode, and are immutable but lack a built-in copyWith; records compile to hidden Record classes and cannot override equality, so list and function contents can break equals semantics. Destructuring works for records, lists, maps and objects (not unordered sets), single-element records require a trailing comma, and future.wait returns typed record for up to nine futures. Switch expressions are exhaustive with sealed classes but differ from switch statements in eight syntax/behavior ways and single-element record needs trailing comma; be cautious changing public APIs because adding record fields is breaking and records are immutable and auto-generate equals/hashCode.
AI-written summary · about
chapters (19)
- 0:00Introduction and context
- 2:12Records in Dart
- 8:53Records pitfalls and immutability
- 12:49Records and code sharing
- 13:09Destructuring records
- 16:42Records in public APIs
- 17:26Single-element records
- 18:08Future.wait with records
- 19:13Destructuring lists and maps
- 21:43Destructuring objects
- 22:04Destructuring state objects
- 23:10Pattern matching introduction
- 25:15Switch expressions vs cases
- 28:49Switch expression features
- 30:15Sealed classes and exhaustiveness
- 31:42If-case pattern matching
- 32:27Matrix matching with records
- 33:29Future of Dart features
- 34:30Call to action and best practices
related talks
37mRecord Patterns - Going Beyond Records - A Deep Dive
31mData Oriented Programming and Matching in Java
42mBetter Modeling Through Records
54mData Oriented Programming with the JDK 19
15mWorld Records - Overview and Use Cases for Records
54mData Focused programming with Pattern Matching in Java
37mRecords, Not Just Constant Classes, A Deep Dive
01h 02mThe Three Amigos: Intermixing Pattern Matching, Records, and Sealed Classes
