whenOrNull<TResult extends Object?> method

  1. @optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
  1. TResult? $default(
    1. String? id,
    2. double reconnectionPercent,
    3. int reconnectionMaximum,
    4. int reconnectionIncidents,
    5. int maxAssets,
    6. int maxDevices,
    7. int maxUsers,
    8. int maxOutboundServices,
    9. int maxFunctions,
    10. int maxApps,
    11. List<String> allowedAppsIds,
    12. List<String> allowedAlgorithmsIds,
    13. List<String> allowedInboundProtocolsIds,
    14. List<String> allowedOutboundProtocolsIds,
    15. List<String> allowedVisionProtocolsIds,
    16. List<String> allowedExchangeProtocolsIds,
    17. bool aiEnabled,
    )?
)

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( String? id,  double reconnectionPercent,  int reconnectionMaximum,  int reconnectionIncidents,  int maxAssets,  int maxDevices,  int maxUsers,  int maxOutboundServices,  int maxFunctions,  int maxApps,  List<String> allowedAppsIds,  List<String> allowedAlgorithmsIds,  List<String> allowedInboundProtocolsIds,  List<String> allowedOutboundProtocolsIds,  List<String> allowedVisionProtocolsIds,  List<String> allowedExchangeProtocolsIds,  bool aiEnabled)?  $default,) {final _that = this;
switch (_that) {
case _BillingPlanInput() when $default != null:
return $default(_that.id,_that.reconnectionPercent,_that.reconnectionMaximum,_that.reconnectionIncidents,_that.maxAssets,_that.maxDevices,_that.maxUsers,_that.maxOutboundServices,_that.maxFunctions,_that.maxApps,_that.allowedAppsIds,_that.allowedAlgorithmsIds,_that.allowedInboundProtocolsIds,_that.allowedOutboundProtocolsIds,_that.allowedVisionProtocolsIds,_that.allowedExchangeProtocolsIds,_that.aiEnabled);case _:
  return null;

}
}