whenOrNull<TResult extends Object?> method
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 id, String name, String? url, @JsonKey(name: 'image_path') String? imagePath, String? details, int? rating100, @JsonKey(name: 'scene_count') int sceneCount, @JsonKey(name: 'image_count') int imageCount, @JsonKey(name: 'gallery_count') int galleryCount, @JsonKey(name: 'performer_count') int performerCount, bool favorite)? $default,) {final _that = this;
switch (_that) {
case _Studio() when $default != null:
return $default(_that.id,_that.name,_that.url,_that.imagePath,_that.details,_that.rating100,_that.sceneCount,_that.imageCount,_that.galleryCount,_that.performerCount,_that.favorite);case _:
return null;
}
}