whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? $default(
- String title,
- String version,
- @JsonKey.new(includeIfNull: false) String? description,
- @JsonKey.new(includeIfNull: false) String? termsOfService,
- @JsonKey.new(includeIfNull: false) Contact? contact,
- @JsonKey.new(includeIfNull: false) License? license,
- @JsonKey.new(includeIfNull: false) String? summary,
- @JsonKey.new(includeIfNull: false, includeFromJson: false, includeToJson: false) Map<
String, dynamic> ? extensions,
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 version, @JsonKey(includeIfNull: false) String? description, @JsonKey(includeIfNull: false) String? termsOfService, @JsonKey(includeIfNull: false) Contact? contact, @JsonKey(includeIfNull: false) License? license, @JsonKey(includeIfNull: false) String? summary, @JsonKey(includeIfNull: false, includeFromJson: false, includeToJson: false) Map<String, dynamic>? extensions)? $default,) {final _that = this;
switch (_that) {
case _Info() when $default != null:
return $default(_that.title,_that.version,_that.description,_that.termsOfService,_that.contact,_that.license,_that.summary,_that.extensions);case _:
return null;
}
}