flutter - Whats ?? = Dart中的运算符

标签 flutter dart operators

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

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

最佳答案

?? =是一个新的空感知运算符。具体地说,?? =是可识别空值的赋值运算符。

?? if null operator. expr1 ?? expr2 evaluates to expr1 if not null, otherwise expr2.


??= null-aware assignment. v ??= expr causes v to be assigned expr only if v is null.


?. null-aware access. x?.p evaluates to x.p if x is not null, otherwise evaluates to null.

关于flutter - Whats ?? = Dart中的运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64642572/

相关文章:

flutter - 在 flutter 中为不同的 ThemeData 自定义颜色

flutter - 在flutter中将自定义透明度值设置为floatingActionButton

c++ - 我需要手动声明 >= 和 <= 运算符吗?

c# - 如何使 += 运算符保留对象引用?

flutter - 没有为类型 "TextTheme"定义 getter 标题

带有 if 语句的 Flutter Firestore FutureBuilder 过滤器

dart - 如何使用Decorator添加带有angular-dart组件的html

flutter - 如何改变 MaterialPageRoute 的状态?

c++ - 重新定义运算符 c++

flutter - 如何防止 Row 占用所有可用宽度?