Option<T>.from constructor

Option<T>.from(
  1. T? value
)

Creates an Option from the given nullable T value.

Creates:

  • Some if the given value is not null.
  • None if the given value is null.

Implementation

factory Option.from(T? value) {
  return switch (value) {
    null => None(),
    _ => Some(value),
  };
}