maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String id,
    2. String name,
    3. OperationType operationType,
    4. HttpRequestType? requestType,
    5. String? url,
    6. List<HttpHeader>? headers,
    7. String? payload,
    8. String? languageId,
    9. Timezone? timezone,
    10. String? timezoneId,
    11. List<String>? receptionEmails,
    12. String? emailSubject,
    13. Color? color,
    14. Color? textColor,
    15. List<PhoneNumber>? destinationPhones,
    16. NotificationType? notificationType,
    17. String? externalAccountId,
    18. List<Access>? access,
    19. List<Trigger>? triggers,
    20. bool? useAssetContactsInstead,
    21. bool? attachImage,
    22. String? emailTemplateId,
    23. List<AppPlatform>? pushPlatforms,
    24. String? pushTitle,
    25. SoundEffect soundEffect,
    26. String? soundEffectUri,
    27. LayrzIcon? icon,
    28. Duration? duration,
    )?, {
  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 id,  String name, @JsonKey(unknownEnumValue: OperationType.unknown)  OperationType operationType, @JsonKey(unknownEnumValue: HttpRequestType.httpGet)  HttpRequestType? requestType,  String? url,  List<HttpHeader>? headers,  String? payload,  String? languageId,  Timezone? timezone,  String? timezoneId,  List<String>? receptionEmails,  String? emailSubject, @ColorOrNullConverter()  Color? color, @ColorOrNullConverter()  Color? textColor,  List<PhoneNumber>? destinationPhones, @JsonKey(unknownEnumValue: NotificationType.unknown)  NotificationType? notificationType,  String? externalAccountId,  List<Access>? access,  List<Trigger>? triggers,  bool? useAssetContactsInstead,  bool? attachImage,  String? emailTemplateId, @JsonKey(unknownEnumValue: AppPlatform.web)  List<AppPlatform>? pushPlatforms,  String? pushTitle, @JsonKey(unknownEnumValue: SoundEffect.none)  SoundEffect soundEffect,  String? soundEffectUri, @IconOrNullConverter()  LayrzIcon? icon, @DurationOrNullConverter()  Duration? duration)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Operation() when $default != null:
return $default(_that.id,_that.name,_that.operationType,_that.requestType,_that.url,_that.headers,_that.payload,_that.languageId,_that.timezone,_that.timezoneId,_that.receptionEmails,_that.emailSubject,_that.color,_that.textColor,_that.destinationPhones,_that.notificationType,_that.externalAccountId,_that.access,_that.triggers,_that.useAssetContactsInstead,_that.attachImage,_that.emailTemplateId,_that.pushPlatforms,_that.pushTitle,_that.soundEffect,_that.soundEffectUri,_that.icon,_that.duration);case _:
  return orElse();

}
}