whenOrNull<TResult extends Object?> method

  1. @optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
  1. TResult? $default(
    1. CardElementClasses? classes,
    2. dynamic style,
    3. String? value,
    4. bool? hidePostalCode,
    5. CardElementIconStyle? iconStyle,
    6. bool? hideIcon,
    7. bool? disabled,
    )?
)

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( CardElementClasses? classes,  dynamic style,  String? value,  bool? hidePostalCode,  CardElementIconStyle? iconStyle,  bool? hideIcon,  bool? disabled)?  $default,) {final _that = this;
switch (_that) {
case _CardElementOptions() when $default != null:
return $default(_that.classes,_that.style,_that.value,_that.hidePostalCode,_that.iconStyle,_that.hideIcon,_that.disabled);case _:
  return null;

}
}