when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>({
  1. required TResult object(
    1. String? title,
    2. String? description,
    3. @JsonKey.new(name: 'default') dynamic defaultValue,
    4. @JsonKey.new(name: '\$ref') String? ref,
    5. List<Schema>? allOf,
    6. List<Schema>? oneOf,
    7. List<Schema>? anyOf,
    8. List<String>? required,
    9. Discriminator? discriminator,
    10. ExternalDocs? externalDocs,
    11. Map<String, Schema>? properties,
    12. bool? nullable,
    13. Xml? xml,
    ),
  2. required TResult boolean(
    1. Xml? xml,
    2. String? title,
    3. String? description,
    4. @JsonKey.new(name: 'default') bool? defaultValue,
    5. bool? nullable,
    6. bool? example,
    7. @JsonKey.new(name: '\$ref') String? ref,
    ),
  3. required TResult string(
    1. Xml? xml,
    2. String? title,
    3. String? description,
    4. @JsonKey.new(name: 'default') String? defaultValue,
    5. bool? nullable,
    6. @JsonKey.new(unknownEnumValue: JsonKey.nullForUndefinedEnumValue) StringFormat? format,
    7. String? pattern,
    8. String? example,
    9. @JsonKey.new(fromJson: _fromJsonInt) int? minLength,
    10. @JsonKey.new(fromJson: _fromJsonInt) int? maxLength,
    11. @JsonKey.new(fromJson: _fromJsonInt) int? exclusiveMinimum,
    12. @JsonKey.new(fromJson: _fromJsonInt) int? exclusiveMaximum,
    13. @JsonKey.new(name: '\$ref') String? ref,
    ),
  4. required TResult integer(
    1. Xml? xml,
    2. String? title,
    3. String? description,
    4. @JsonKey.new(name: 'default', fromJson: _fromJsonInt) int? defaultValue,
    5. bool? nullable,
    6. @JsonKey.new(unknownEnumValue: JsonKey.nullForUndefinedEnumValue) IntegerFormat? format,
    7. @JsonKey.new(fromJson: _fromJsonInt) int? example,
    8. @JsonKey.new(fromJson: _fromJsonInt) int? minimum,
    9. @JsonKey.new(fromJson: _fromJsonInt) int? maximum,
    10. @JsonKey.new(fromJson: _fromJsonInt) int? exclusiveMinimum,
    11. @JsonKey.new(fromJson: _fromJsonInt) int? exclusiveMaximum,
    12. @JsonKey.new(fromJson: _fromJsonInt) int? multipleOf,
    13. @JsonKey.new(name: '\$ref') String? ref,
    ),
  5. required TResult number(
    1. Xml? xml,
    2. String? title,
    3. String? description,
    4. @JsonKey.new(name: 'default', fromJson: _fromJsonDouble) double? defaultValue,
    5. bool? nullable,
    6. @JsonKey.new(unknownEnumValue: JsonKey.nullForUndefinedEnumValue) NumberFormat? format,
    7. @JsonKey.new(fromJson: _fromJsonDouble) double? example,
    8. @JsonKey.new(fromJson: _fromJsonDouble) double? minimum,
    9. @JsonKey.new(fromJson: _fromJsonDouble) double? maximum,
    10. @JsonKey.new(fromJson: _fromJsonInt) int? exclusiveMinimum,
    11. @JsonKey.new(fromJson: _fromJsonInt) int? exclusiveMaximum,
    12. @JsonKey.new(fromJson: _fromJsonDouble) double? multipleOf,
    13. @JsonKey.new(name: '\$ref') String? ref,
    ),
  6. required TResult enumeration(
    1. String? title,
    2. String? description,
    3. String? example,
    4. @JsonKey.new(name: 'default') String? defaultValue,
    5. bool? nullable,
    6. @JsonKey.new(includeToJson: false, includeFromJson: false) String? unknownValue,
    7. @JsonKey.new(name: 'enum') List<String>? values,
    8. @JsonKey.new(name: '\$ref') String? ref,
    ),
  7. required TResult array(
    1. Xml? xml,
    2. String? title,
    3. String? description,
    4. @JsonKey.new(name: 'default') List? defaultValue,
    5. bool? nullable,
    6. dynamic example,
    7. @JsonKey.new(fromJson: _fromJsonInt) int? minItems,
    8. @JsonKey.new(fromJson: _fromJsonInt) int? maxItems,
    9. Schema items,
    10. @JsonKey.new(name: '\$ref') String? ref,
    ),
  8. required TResult map(
    1. Xml? xml,
    2. String? title,
    3. String? description,
    4. @JsonKey.new(name: 'default') Map? defaultValue,
    5. bool? nullable,
    6. Map? example,
    7. @JsonKey.new(name: 'additionalProperties', toJson: _toMapProps, fromJson: _fromMapProps) Schema? valueSchema,
    8. @JsonKey.new(name: '\$ref') String? ref,
    ),
})

A switch-like method, using callbacks.

As opposed to map, this offers destructuring. It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case Subclass2(:final field2):
    return ...;
}

Implementation

@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function( String? title,  String? description, @JsonKey(name: 'default')  dynamic defaultValue, @JsonKey(name: '\$ref')@_SchemaRefConverter()  String? ref, @_SchemaListConverter()  List<Schema>? allOf, @_SchemaListConverter()  List<Schema>? oneOf, @_SchemaListConverter()  List<Schema>? anyOf,  List<String>? required,  Discriminator? discriminator,  ExternalDocs? externalDocs,  Map<String, Schema>? properties,  bool? nullable,  Xml? xml)  object,required TResult Function( Xml? xml,  String? title,  String? description, @JsonKey(name: 'default')  bool? defaultValue,  bool? nullable,  bool? example, @JsonKey(name: '\$ref')@_SchemaRefConverter()  String? ref)  boolean,required TResult Function( Xml? xml,  String? title,  String? description, @JsonKey(name: 'default')  String? defaultValue,  bool? nullable, @JsonKey(unknownEnumValue: JsonKey.nullForUndefinedEnumValue)  StringFormat? format,  String? pattern,  String? example, @JsonKey(fromJson: _fromJsonInt)  int? minLength, @JsonKey(fromJson: _fromJsonInt)  int? maxLength, @JsonKey(fromJson: _fromJsonInt)  int? exclusiveMinimum, @JsonKey(fromJson: _fromJsonInt)  int? exclusiveMaximum, @JsonKey(name: '\$ref')@_SchemaRefConverter()  String? ref)  string,required TResult Function( Xml? xml,  String? title,  String? description, @JsonKey(name: 'default', fromJson: _fromJsonInt)  int? defaultValue,  bool? nullable, @JsonKey(unknownEnumValue: JsonKey.nullForUndefinedEnumValue)  IntegerFormat? format, @JsonKey(fromJson: _fromJsonInt)  int? example, @JsonKey(fromJson: _fromJsonInt)  int? minimum, @JsonKey(fromJson: _fromJsonInt)  int? maximum, @JsonKey(fromJson: _fromJsonInt)  int? exclusiveMinimum, @JsonKey(fromJson: _fromJsonInt)  int? exclusiveMaximum, @JsonKey(fromJson: _fromJsonInt)  int? multipleOf, @JsonKey(name: '\$ref')@_SchemaRefConverter()  String? ref)  integer,required TResult Function( Xml? xml,  String? title,  String? description, @JsonKey(name: 'default', fromJson: _fromJsonDouble)  double? defaultValue,  bool? nullable, @JsonKey(unknownEnumValue: JsonKey.nullForUndefinedEnumValue)  NumberFormat? format, @JsonKey(fromJson: _fromJsonDouble)  double? example, @JsonKey(fromJson: _fromJsonDouble)  double? minimum, @JsonKey(fromJson: _fromJsonDouble)  double? maximum, @JsonKey(fromJson: _fromJsonInt)  int? exclusiveMinimum, @JsonKey(fromJson: _fromJsonInt)  int? exclusiveMaximum, @JsonKey(fromJson: _fromJsonDouble)  double? multipleOf, @JsonKey(name: '\$ref')@_SchemaRefConverter()  String? ref)  number,required TResult Function( String? title,  String? description,  String? example, @JsonKey(name: 'default')  String? defaultValue,  bool? nullable, @JsonKey(includeToJson: false, includeFromJson: false)  String? unknownValue, @JsonKey(name: 'enum')  List<String>? values, @JsonKey(name: '\$ref')@_SchemaRefConverter()  String? ref)  enumeration,required TResult Function( Xml? xml,  String? title,  String? description, @JsonKey(name: 'default')  List? defaultValue,  bool? nullable,  dynamic example, @JsonKey(fromJson: _fromJsonInt)  int? minItems, @JsonKey(fromJson: _fromJsonInt)  int? maxItems,  Schema items, @JsonKey(name: '\$ref')@_SchemaRefConverter()  String? ref)  array,required TResult Function( Xml? xml,  String? title,  String? description, @JsonKey(name: 'default')  Map? defaultValue,  bool? nullable,  Map? example, @JsonKey(name: 'additionalProperties', toJson: _toMapProps, fromJson: _fromMapProps)  Schema? valueSchema, @JsonKey(name: '\$ref')@_SchemaRefConverter()  String? ref)  map,}) {final _that = this;
switch (_that) {
case SchemaObject():
return object(_that.title,_that.description,_that.defaultValue,_that.ref,_that.allOf,_that.oneOf,_that.anyOf,_that.required,_that.discriminator,_that.externalDocs,_that.properties,_that.nullable,_that.xml);case SchemaBoolean():
return boolean(_that.xml,_that.title,_that.description,_that.defaultValue,_that.nullable,_that.example,_that.ref);case SchemaString():
return string(_that.xml,_that.title,_that.description,_that.defaultValue,_that.nullable,_that.format,_that.pattern,_that.example,_that.minLength,_that.maxLength,_that.exclusiveMinimum,_that.exclusiveMaximum,_that.ref);case SchemaInteger():
return integer(_that.xml,_that.title,_that.description,_that.defaultValue,_that.nullable,_that.format,_that.example,_that.minimum,_that.maximum,_that.exclusiveMinimum,_that.exclusiveMaximum,_that.multipleOf,_that.ref);case SchemaNumber():
return number(_that.xml,_that.title,_that.description,_that.defaultValue,_that.nullable,_that.format,_that.example,_that.minimum,_that.maximum,_that.exclusiveMinimum,_that.exclusiveMaximum,_that.multipleOf,_that.ref);case SchemaEnum():
return enumeration(_that.title,_that.description,_that.example,_that.defaultValue,_that.nullable,_that.unknownValue,_that.values,_that.ref);case SchemaArray():
return array(_that.xml,_that.title,_that.description,_that.defaultValue,_that.nullable,_that.example,_that.minItems,_that.maxItems,_that.items,_that.ref);case SchemaMap():
return map(_that.xml,_that.title,_that.description,_that.defaultValue,_that.nullable,_that.example,_that.valueSchema,_that.ref);case _:
  throw StateError('Unexpected subclass');

}
}