getOrNull method
T?
getOrNull()
Returns the encapsulated value if this instance represents Success or null
if it is Failure.
This function is a shorthand for getOrElse(() => null)
or
fold(onSuccess: (it) => it, onFailure: (_) => null)
.
Implementation
T? getOrNull() {
return switch (this) {
Success<T>(:final data) => data,
Failure() => null,
};
}