whenOrNull<TResult extends Object?> method
TResult?
whenOrNull<TResult extends Object?>(
- TResult? $default(
- Color background,
- Color foreground,
- Color borderColor,
- Color loadingColor,
- Color disableBackground,
- double borderWidth,
- bool isEnable,
- double elevation,
- double paddingHorizontal,
- double paddingVertical,
- double textSize,
- Widget? prefixIcon,
- Widget? suffixIcon,
- Widget? centerIcon,
- TextStyle? textStyle,
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( Color background, Color foreground, Color borderColor, Color loadingColor, Color disableBackground, double borderWidth, bool isEnable, double elevation, double paddingHorizontal, double paddingVertical, double textSize, Widget? prefixIcon, Widget? suffixIcon, Widget? centerIcon, TextStyle? textStyle)? $default,) {final _that = this;
switch (_that) {
case _XButtonStyle() when $default != null:
return $default(_that.background,_that.foreground,_that.borderColor,_that.loadingColor,_that.disableBackground,_that.borderWidth,_that.isEnable,_that.elevation,_that.paddingHorizontal,_that.paddingVertical,_that.textSize,_that.prefixIcon,_that.suffixIcon,_that.centerIcon,_that.textStyle);case _:
return null;
}
}