valueOrNull property

T? get valueOrNull

The value, or null when absent.

Convenience for callers that want T? without pattern matching: an absent field yields null, a present field yields its value. For a Field<T?> whose value is null, this still returns null — the two are distinguishable through isAbsent / isPresent when it matters.

Implementation

T? get valueOrNull => switch (this) {
  AbsentField<T>() => null,
  ValueField<T>(:final value) => value,
};