orElse method
- @useResult
- T f()
Returns the value if it's not a null, otherwise calls f and
returns the result.
The function f won't be evaluated if the value is not null,
for example:
instance.orElse(() => throw StateError('instance cannot be null'));
If instance is not null, the throwing function is never called.
Implementation
@useResult
T orElse(T Function() f) => this != null ? this as T : f();