Null aware operators in dart

Null-aware operators in dart use to check wether the value is null or not.

Null coalescing operator

?? :-

this opertor provide default value if the variable is null.


?. :-

this operator is used for calling the particular function based on null check.


Null-aware spread operator


to avoid null value in a list you can use this operator.

var list = [
  ...["hello", "world"],

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

Leave a Comment