maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. Color? backgroundColor,
    2. Color? foregroundColor,
    3. Color? evenBackgroundColor,
    4. Color? evenForegroundColor,
    5. Color? hoverBackgroundColor,
    6. Color? evenHoverBackgroundColor,
    7. SelectedTileColor selectedColor,
    8. TextStyle? textStyle,
    9. Widget? trailingIcon,
    10. bool withCheckboxIcon,
    11. Widget? checkboxIcon,
    12. Widget? selectedCheckboxIcon,
    )?, {
  2. required TResult orElse(),
})

A variant of when that fallback to an orElse callback.

It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case _:
    return orElse();
}

Implementation

@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( Color? backgroundColor,  Color? foregroundColor,  Color? evenBackgroundColor,  Color? evenForegroundColor,  Color? hoverBackgroundColor,  Color? evenHoverBackgroundColor,  SelectedTileColor selectedColor,  TextStyle? textStyle,  Widget? trailingIcon,  bool withCheckboxIcon,  Widget? checkboxIcon,  Widget? selectedCheckboxIcon)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _ListDataTileStyle() when $default != null:
return $default(_that.backgroundColor,_that.foregroundColor,_that.evenBackgroundColor,_that.evenForegroundColor,_that.hoverBackgroundColor,_that.evenHoverBackgroundColor,_that.selectedColor,_that.textStyle,_that.trailingIcon,_that.withCheckboxIcon,_that.checkboxIcon,_that.selectedCheckboxIcon);case _:
  return orElse();

}
}