whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? $default(
- String elementType,
- bool empty,
- bool complete,
- StripeError? error,
- String brand,
- CardElementChangeEventValue? value,
A variant of when
that fallback to returning null
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case _:
return null;
}
Implementation
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String elementType, bool empty, bool complete, StripeError? error, String brand, CardElementChangeEventValue? value)? $default,) {final _that = this;
switch (_that) {
case _CardElementChangeEvent() when $default != null:
return $default(_that.elementType,_that.empty,_that.complete,_that.error,_that.brand,_that.value);case _:
return null;
}
}