Skip to content

Switch Matrix in Dart 3

Did you know?

Since Dart 3, you can combine multiple variables into a record and replace if-else chains with a switch expression. ✅

This is known as a switch matrix and lets you apply pattern matching to multiple values at once. 👌


This tip was inspired by Pascal Welsch’s talk about Records and patterns at FlutterCon.

Slides here:

Previous Next
Destructuring Lists in Dart Conditional JSON parsing in Dart 3

Last update: 18 septembre 2023
Created: 18 septembre 2023