Skip to content

Latest commit

 

History

History
28 lines (21 loc) · 573 Bytes

prefer_conditional_assignment.md

File metadata and controls

28 lines (21 loc) · 573 Bytes

Pattern: Missing use of ??=

Issue: -

Description

As Dart has the ??= operator, it is advisable to use it where applicable to improve the brevity of your code.

Example of incorrect code:

String get fullName {
 if (_fullName == null) {
  _fullName = getFullUserName(this);
 }
 return _fullName;
}

Example of correct code:

String get fullName {
 return _fullName ??= getFullUserName(this);;
}

Further Reading