when<TResult extends Object?> method
- @optionalTypeArgs
- TResult $default(
- CardElementClasses? classes,
- dynamic style,
- String? value,
- bool? hidePostalCode,
- CardElementIconStyle? iconStyle,
- bool? hideIcon,
- bool? disabled,
A switch
-like method, using callbacks.
As opposed to map
, this offers destructuring.
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case Subclass2(:final field2):
return ...;
}
Implementation
@optionalTypeArgs TResult when<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():
return $default(_that.classes,_that.style,_that.value,_that.hidePostalCode,_that.iconStyle,_that.hideIcon,_that.disabled);case _:
throw StateError('Unexpected subclass');
}
}