whenOrNull<TResult extends Object?> method

  1. @optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
  1. TResult? object(
    1. String? title,
    2. String? description,
    3. dynamic defaultValue,
    4. 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. TResult? boolean(
    1. Xml? xml,
    2. String? title,
    3. String? description,
    4. bool? defaultValue,
    5. bool? nullable,
    6. bool? example,
    7. String? ref,
    )?,
  3. TResult? string(
    1. Xml? xml,
    2. String? title,
    3. String? description,
    4. String? defaultValue,
    5. bool? nullable,
    6. StringFormat? format,
    7. String? pattern,
    8. String? example,
    9. int? minLength,
    10. int? maxLength,
    11. int? exclusiveMinimum,
    12. int? exclusiveMaximum,
    13. String? ref,
    )?,
  4. TResult? integer(
    1. Xml? xml,
    2. String? title,
    3. String? description,
    4. int? defaultValue,
    5. bool? nullable,
    6. IntegerFormat? format,
    7. int? example,
    8. int? minimum,
    9. int? maximum,
    10. int? exclusiveMinimum,
    11. int? exclusiveMaximum,
    12. int? multipleOf,
    13. String? ref,
    )?,
  5. TResult? number(
    1. Xml? xml,
    2. String? title,
    3. String? description,
    4. double? defaultValue,
    5. bool? nullable,
    6. NumberFormat? format,
    7. double? example,
    8. double? minimum,
    9. double? maximum,
    10. int? exclusiveMinimum,
    11. int? exclusiveMaximum,
    12. double? multipleOf,
    13. String? ref,
    )?,
  6. TResult? enumeration(
    1. String? title,
    2. String? description,
    3. String? example,
    4. String? defaultValue,
    5. bool? nullable,
    6. String? unknownValue,
    7. List<String>? values,
    8. String? ref,
    )?,
  7. TResult? array(
    1. Xml? xml,
    2. String? title,
    3. String? description,
    4. List? defaultValue,
    5. bool? nullable,
    6. dynamic example,
    7. int? minItems,
    8. int? maxItems,
    9. Schema items,
    10. String? ref,
    )?,
  8. TResult? map(
    1. Xml? xml,
    2. String? title,
    3. String? description,
    4. Map? defaultValue,
    5. bool? nullable,
    6. Map? example,
    7. Schema? valueSchema,
    8. String? ref,
    )?,
})

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? 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,TResult? Function( Xml? xml,  String? title,  String? description, @JsonKey(name: 'default')  bool? defaultValue,  bool? nullable,  bool? example, @JsonKey(name: '\$ref')@_SchemaRefConverter()  String? ref)?  boolean,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,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,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,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,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,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() when object != null:
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() when boolean != null:
return boolean(_that.xml,_that.title,_that.description,_that.defaultValue,_that.nullable,_that.example,_that.ref);case SchemaString() when string != null:
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() when integer != null:
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() when number != null:
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() when enumeration != null:
return enumeration(_that.title,_that.description,_that.example,_that.defaultValue,_that.nullable,_that.unknownValue,_that.values,_that.ref);case SchemaArray() when array != null:
return array(_that.xml,_that.title,_that.description,_that.defaultValue,_that.nullable,_that.example,_that.minItems,_that.maxItems,_that.items,_that.ref);case SchemaMap() when map != null:
return map(_that.xml,_that.title,_that.description,_that.defaultValue,_that.nullable,_that.example,_that.valueSchema,_that.ref);case _:
  return null;

}
}