Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What means the operator "??" in Dart/Flutter? [duplicate]

I've seen this code and need an explanation for "??". I know ternary operators like "?" and then the true-condition and after ":" the false/else condition. But what means the double "??" ?

Thanks in advance

      widget.secondaryImageTop ??
      (widget.height / 2) - (widget.secondaryImageHeight / 2); ```
like image 686
cyberpVnk Avatar asked Nov 03 '20 13:11

cyberpVnk


1 Answers

List of all dart operators

it's the coalesce operator.

a ?? b

means: if a is not null, it resolves to a. if a is null, it resolves to b.

SQL and a few other languages have this operator.

like image 107
rzwitserloot Avatar answered Sep 27 '22 21:09

rzwitserloot