Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteIn Dart 3.0 or later, swap two local variables with a record assignment pattern: (b, a) = (a, b);. The right side carries their current values, and the left-side pattern assigns them in reverse order.
Swap two local variables with a record pattern
Here is the complete example from the official Dart Patterns guide:
As an Amazon Associate I earn from qualifying purchases.
var (a, b) = ('left', 'right');
(b, a) = (a, b);
print('$a $b'); // right left
The first line declares and initializes a and b. The second line is an assignment to those existing variables, not a declaration of new ones. The record on the right groups their current values; the pattern on the left assigns the positional values to the variables in the opposite order.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Requirements and scope
Dart language version 3.0 or later
Records and patterns require a Dart language version of at least 3.0. If a project is configured for an earlier language version, this syntax is unavailable under that configuration. See the official Dart Records guide and Patterns guide.
#1 Best Overall
Targets must be local variables
Pattern assignment cannot directly target a field or a top-level variable. The analyzer documents this restriction in pattern_assignment_not_local_variable. For a field, first use local variables in the pattern assignment, then assign the desired value to the field separately.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Why this works
A Dart record is a fixed-size, typed aggregate value that can hold values of different types. Its fields have no setters, but the record can carry both current values into an assignment pattern. The pattern assigns those values to the existing local variables; it does not mutate the record.
Rank #2
No arithmetic trick is required. This is a concise language feature, not evidence of a memory saving or a speed improvement; the cited Dart documentation makes no such performance claim.
Quick Recap
Rank #4
Rank #3
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




