fromNullable<R extends Object> static method

Either<void, R> fromNullable<R extends Object>(
  1. R? value
)

Returns a Right if value is not null, otherwise a Left containing null.

Example

Either.fromNullable<String>(null);        // Result: Left(null)
Either.fromNullable<String>('hoc081098'); // Result: Right('hoc081098')

Implementation

static Either<void, R> fromNullable<R extends Object>(R? value) =>
    value == null ? const Either.left(null) : Either.right(value);