whereType<U> method
Returns a Some of the original value if this
is a Some with a contained value of type
U
, or None otherwise.
Examples
// prints "Some(2)"
print(const Some(2).whereType<int>());
// prints "None"
print(const Some(2).whereType<bool>());
Implementation
@override
@useResult
Option<U> whereType<U>() {
final value = this.value;
return value is U ? Some(value) : None<U>();
}