这是我在Flutter源代码中看到的新赋值运算符:
splashFactory ??= InkSplash.splashFactory;
textSelectionColor ??= isDark ? accentColor : primarySwatch[200];
这个赋值运算符是什么意思?example in Flutter source code
最佳答案
?? =是一个新的空感知运算符。具体地说,?? =是可识别空值的赋值运算符。
?? if null operator.
expr1 ?? expr2
evaluates toexpr1
if notnull
, otherwiseexpr2
.
??= null-aware assignment.
v ??= expr
causesv
to be assignedexpr
only ifv
isnull
.
?. null-aware access.
x?.p
evaluates tox.p
ifx
is notnull
, otherwise evaluates tonull
.
关于flutter - Whats ?? = Dart中的运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64642572/