Nullability of types is an important part of Dart’s type system. In order to simplify the work with nullable types in Dart language there are many
null-aware operators (??, ??=, ?., !, ?.., ?[], …?). Using
those operators, will make your code more clear and concise.
Null-aware assignment (??=), will check if the value on the left side is null, and, if yes, will perform the assignment.
This is an easy way to set default values instead of dealing with null. Thus, this operator doesn’t make sense if used with
null on the right side. For example, x ??= null will be reported as an issue.
Exceptions
The rule doesn’t apply if property access is used. For example:
class Person {
String? name;
int? age;
void g() {
name ??= null; // Ok, field
age ??= null; // Ok, field
}
}