Null aware operators in Dart
Posted on 7 Nov, 2021
Null aware operators makes handling real world data very intuitive & easy. Let's have a brief overview of all the 4 null aware operators in Dart.
The ?.
operator
?.
operatorPrevent method call on null objects
This is similar to following code
The ??
operator
??
operatorThis operator can be used to assign a default fallback value.
Return the first expression IFF it is not null.
The ??=
operator
??=
operatorAssign a value IFF it is not null.
The ...?
operator - Null aware spread operator
...?
operator - Null aware spread operatorExpand list elements IFF it's not null
Last updated