whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? object()?,
- TResult? boolean()?,
- TResult? string()?,
- TResult? integer()?,
- TResult? number()?,
- TResult? enumeration()?,
- TResult? array()?,
- TResult? map()?,
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;
}
}