when<TResult extends Object?> method
TResult
when<TResult extends Object?>(
- TResult $default(
- Glyph glyph,
- VoidCallback? onPressed,
- String? tooltip,
- bool isLoading,
- bool? isSelected,
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( Glyph glyph, VoidCallback? onPressed, String? tooltip, bool isLoading, bool? isSelected) $default,) {final _that = this;
switch (_that) {
case _IconButtonData():
return $default(_that.glyph,_that.onPressed,_that.tooltip,_that.isLoading,_that.isSelected);case _:
throw StateError('Unexpected subclass');
}
}