Value<T>.ofNullable constructor

  1. @Deprecated('Use Value.absentIfNull instead')
const Value<T>.ofNullable(
  1. 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

@Deprecated('Use Value.absentIfNull instead')
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;