Option<T extends Object>.from constructor
Option<T extends Object>.from (
- T? value
Creates an Option from a nullable value.
Returns Some if the value
is not null
, otherwise returns None.
Implementation
factory Option.from(T? value) {
// This is already safe and idiomatic, no switch needed here.
if (value != null) {
return Some(value);
} else {
return const None();
}
}