orDefault method
- @useResult
- T defaultValue
Returns this value if non-null, otherwise defaultValue.
A typed shorthand for value ?? defaultValue that reads clearly in chains.
Example:
String? name;
name.orDefault('Anonymous'); // 'Anonymous'
Implementation
@useResult
T orDefault(T defaultValue) => this ?? defaultValue;