whenOrNull<TResult extends Object?> method

  1. @optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
  1. TResult? $default(
    1. VoDashboardPane? currentPane,
    2. List<VoDashboardPane> dockPanes,
    3. List<VoDashboardPane> drawerPanes,
    4. List<VoDashboardPane> endDrawerPanes,
    5. List<VoDashboardPane> registry,
    6. List<VoPage> flowPages,
    7. bool canPopShell,
    8. bool isInitialized,
    )?
)

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( VoDashboardPane? currentPane,  List<VoDashboardPane> dockPanes,  List<VoDashboardPane> drawerPanes,  List<VoDashboardPane> endDrawerPanes,  List<VoDashboardPane> registry,  List<VoPage> flowPages,  bool canPopShell,  bool isInitialized)?  $default,) {final _that = this;
switch (_that) {
case _VoDashboardState() when $default != null:
return $default(_that.currentPane,_that.dockPanes,_that.drawerPanes,_that.endDrawerPanes,_that.registry,_that.flowPages,_that.canPopShell,_that.isInitialized);case _:
  return null;

}
}