Flutter Dart ?问号是什么意思
String? name;
加⼀个问号可以让静态检查通过,表⽰可空类型,String? 则是可空类型 String。
String a = b ??‘hello’;
赋值: b不空则a等于b ; b为null,则a等于’hello’。
b ??=‘hello’;
如果b为null则其赋值为hello。否则不会改动。
a?.p a?.m()
如果a为空,则直接返回null不执行后边的操作。
参考:
https://wenku.baidu.com/view/b162a4ce9a8fcc22bcd126fff705cc1755275f35.html
https://www.jianshu.com/p/94e3a6a220b0