Value<T>.ofNullable constructor
const
Value<T>.ofNullable (
- T? value
Create a value that is absent if value is null and present if it's
not.
The functionality is equiavalent to the following:
x != null ? Value(x) : Value.absent().
This constructor should only be used when T is not nullable. If T were
nullable, there wouldn't be a clear interpretation for a null value.
See the overall documentation on Value for details.
Implementation
const Value.ofNullable(T? value)
: assert(
value != null || null is! T,
"Value.ofNullable(null) can't be used for a nullable T, since the "
'null value could be both absent and present.',
),
_value = value,
present = value != null;