Flutter 什么???=省道中的操作员

Flutter 什么???=省道中的操作员,flutter,dart,operators,Flutter,Dart,Operators,这是我在颤振源代码中看到的新赋值运算符: splashFactory ??= InkSplash.splashFactory; textSelectionColor ??= isDark ? accentColor : primarySwatch[200]; 这个赋值运算符是什么意思 ??双问号运算符表示“如果为空”,请使用以下表达式。?是空检查运算符 String name=person.name ?? 'John'; 如果person.name为null,则为name分配一个值“John

这是我在颤振源代码中看到的新赋值运算符:

splashFactory ??= InkSplash.splashFactory;
textSelectionColor ??= isDark ? accentColor : primarySwatch[200];
这个赋值运算符是什么意思


??双问号运算符表示“如果为空”,请使用以下表达式。

是空检查运算符

String name=person.name ?? 'John';
如果person.name为null,则为name分配一个值“John”

??=简单地表示“如果左侧为空,则执行赋值”。这将仅在变量为null时分配一个值

splashFactory ??= InkSplash.splashFactory;

??=是一种新的空感知运算符。具体来说???=是空感知赋值运算符

String name=person.name ?? 'John';
??? 如果为null运算符<代码>expr1??expr2如果不是
null
,则计算为
expr1
,否则
expr2

?= 空感知分配<代码>v???=expr导致分配
v
expr
仅当
v
null

?。 空感知访问<如果
x
不是
null
,则code>x.p计算为
x.p
,否则计算为
null


?? 是空检查运算符。字符串名称=person.name??'约翰;