Null-aware operators in dart
Table of Contents
Null coalescing operator
?? :-
this opertor provide default value if the variable is null.
a??"a";
?. :-
this operator is used for calling the particular function based on null check.
_scrollController?.dispose()
Null-aware spread operator
…?
to avoid null value in a list you can use this operator.
var list = [ ...["hello", "world"], ...?anotherList, ]
Null-aware assignment operator
??=
null check assignment operator is used assigning the default value when varibale is null, it is very similar to this ??
operator.
assign ??= "defaultValue"
Additional resources