maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. @JsonKey.new(name: r'$ref') String? ref,
    2. @JsonKey.new(includeFromJson: false, includeToJson: true) dynamic type,
    3. String? format,
    4. String? title,
    5. String? description,
    6. @JsonKey.new(name: 'required') List<String>? $required,
    7. Map<String, Schema>? properties,
    8. Schema? items,
    9. dynamic example,
    10. List? examples,
    11. @JsonKey.new(name: 'enum') List? enumValues,
    12. @JsonKey.new(name: 'default') dynamic $default,
    13. Xml? xml,
    14. dynamic additionalProperties,
    15. num? maximum,
    16. num? exclusiveMaximum,
    17. num? minimum,
    18. num? exclusiveMinimum,
    19. ExternalDocs? externalDocs,
    20. Discriminator? discriminator,
    21. List<Schema>? allOf,
    22. List<Schema>? oneOf,
    23. List<Schema>? anyOf,
    24. Schema? not,
    25. bool? nullable,
    26. bool? readOnly,
    27. bool? writeOnly,
    28. bool? allowEmptyValue,
    29. String? collectionFormat,
    30. int? maxLength,
    31. int? minLength,
    32. int? maxItems,
    33. int? minItems,
    34. String? pattern,
    35. bool? uniqueItems,
    36. int? maxProperties,
    37. int? minProperties,
    38. num? multipleOf,
    39. @JsonKey.new(name: 'deprecated') bool? $deprecated,
    40. @JsonKey.new(includeIfNull: false, includeFromJson: false, includeToJson: false) Map<String, dynamic>? extensions,
    41. String? $id,
    42. String? $schema,
    43. String? $vocabulary,
    44. String? $anchor,
    45. String? $dynamicAnchor,
    46. String? $dynamicRef,
    47. Map<String, Schema>? $defs,
    48. String? contentMediaType,
    49. String? contentEncoding,
    50. @JsonKey.new(name: 'swagger-extension') bool? swaggerExtension,
    51. @JsonKey.new(name: 'const') dynamic const$,
    52. Map<String, Schema>? patternProperties,
    53. bool? unevaluatedProperties,
    )?, {
  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(@JsonKey(name: r'$ref')  String? ref, @JsonKey(includeFromJson: false, includeToJson: true)  dynamic type,  String? format,  String? title,  String? description, @JsonKey(name: 'required')  List<String>? $required,  Map<String, Schema>? properties,  Schema? items,  dynamic example,  List<dynamic>? examples, @JsonKey(name: 'enum')  List<dynamic>? enumValues, @JsonKey(name: 'default')  dynamic $default,  Xml? xml,  dynamic additionalProperties,  num? maximum,  num? exclusiveMaximum,  num? minimum,  num? exclusiveMinimum,  ExternalDocs? externalDocs,  Discriminator? discriminator,  List<Schema>? allOf,  List<Schema>? oneOf,  List<Schema>? anyOf,  Schema? not,  bool? nullable,  bool? readOnly,  bool? writeOnly,  bool? allowEmptyValue,  String? collectionFormat,  int? maxLength,  int? minLength,  int? maxItems,  int? minItems,  String? pattern,  bool? uniqueItems,  int? maxProperties,  int? minProperties,  num? multipleOf, @JsonKey(name: 'deprecated')  bool? $deprecated, @JsonKey(includeIfNull: false, includeFromJson: false, includeToJson: false)  Map<String, dynamic>? extensions,  String? $id,  String? $schema,  String? $vocabulary,  String? $anchor,  String? $dynamicAnchor,  String? $dynamicRef,  Map<String, Schema>? $defs,  String? contentMediaType,  String? contentEncoding, @JsonKey(name: 'swagger-extension')  bool? swaggerExtension, @JsonKey(name: 'const')  dynamic const$,  Map<String, Schema>? patternProperties,  bool? unevaluatedProperties)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Schema() when $default != null:
return $default(_that.ref,_that.type,_that.format,_that.title,_that.description,_that.$required,_that.properties,_that.items,_that.example,_that.examples,_that.enumValues,_that.$default,_that.xml,_that.additionalProperties,_that.maximum,_that.exclusiveMaximum,_that.minimum,_that.exclusiveMinimum,_that.externalDocs,_that.discriminator,_that.allOf,_that.oneOf,_that.anyOf,_that.not,_that.nullable,_that.readOnly,_that.writeOnly,_that.allowEmptyValue,_that.collectionFormat,_that.maxLength,_that.minLength,_that.maxItems,_that.minItems,_that.pattern,_that.uniqueItems,_that.maxProperties,_that.minProperties,_that.multipleOf,_that.$deprecated,_that.extensions,_that.$id,_that.$schema,_that.$vocabulary,_that.$anchor,_that.$dynamicAnchor,_that.$dynamicRef,_that.$defs,_that.contentMediaType,_that.contentEncoding,_that.swaggerExtension,_that.const$,_that.patternProperties,_that.unevaluatedProperties);case _:
  return orElse();

}
}