whenOrNull<TResult extends Object?> method
TResult?
whenOrNull<TResult extends Object?>(
- TResult? $default(
- String id,
- String name,
- Map<
String, dynamic> ? credentials, - OutboundProtocol? protocol,
- String? protocolId,
- bool? isEnabled,
- List<
OutboundStructure> ? structure, - String? token,
- List<
String> ? assetsIds, - List<
Asset> ? assets, - List<
String> ? groupsIds, - List<
Tag> ? groups, - List<
Access> ? access, - OutboundMetrics? metrics,
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, String name, Map<String, dynamic>? credentials, OutboundProtocol? protocol, String? protocolId, bool? isEnabled, List<OutboundStructure>? structure, String? token, List<String>? assetsIds, List<Asset>? assets, List<String>? groupsIds, List<Tag>? groups, List<Access>? access, OutboundMetrics? metrics)? $default,) {final _that = this;
switch (_that) {
case _OutboundService() when $default != null:
return $default(_that.id,_that.name,_that.credentials,_that.protocol,_that.protocolId,_that.isEnabled,_that.structure,_that.token,_that.assetsIds,_that.assets,_that.groupsIds,_that.groups,_that.access,_that.metrics);case _:
return null;
}
}