maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String? ruleTag,
    2. String? outboundTag,
    3. String? balancerTag,
    4. XrayStringList? domain,
    5. XrayStringList? domains,
    6. XrayStringList? ip,
    7. XrayPortList? port,
    8. XrayNetworkList? network,
    9. XrayStringList? sourceIP,
    10. XrayStringList? source,
    11. XrayPortList? sourcePort,
    12. XrayStringList? user,
    13. XrayPortList? vlessRoute,
    14. XrayStringList? inboundTag,
    15. @JsonKey.new(name: 'protocol') XrayStringList? protocols,
    16. @JsonKey.new(name: 'attrs') Map<String, String>? attributes,
    17. XrayStringList? localIP,
    18. XrayPortList? localPort,
    19. XrayStringList? process,
    20. WebhookRuleConfig? webhook,
    )?, {
  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( String? ruleTag,  String? outboundTag,  String? balancerTag,  XrayStringList? domain,  XrayStringList? domains,  XrayStringList? ip,  XrayPortList? port,  XrayNetworkList? network,  XrayStringList? sourceIP,  XrayStringList? source,  XrayPortList? sourcePort,  XrayStringList? user,  XrayPortList? vlessRoute,  XrayStringList? inboundTag, @JsonKey(name: 'protocol')  XrayStringList? protocols, @JsonKey(name: 'attrs')  Map<String, String>? attributes,  XrayStringList? localIP,  XrayPortList? localPort,  XrayStringList? process,  WebhookRuleConfig? webhook)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _RouterRule() when $default != null:
return $default(_that.ruleTag,_that.outboundTag,_that.balancerTag,_that.domain,_that.domains,_that.ip,_that.port,_that.network,_that.sourceIP,_that.source,_that.sourcePort,_that.user,_that.vlessRoute,_that.inboundTag,_that.protocols,_that.attributes,_that.localIP,_that.localPort,_that.process,_that.webhook);case _:
  return orElse();

}
}