when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. String id,
    2. String name,
    3. String? disambiguation,
    4. List<String> urls,
    5. String? gender,
    6. String? birthdate,
    7. String? ethnicity,
    8. String? country,
    9. String? eyeColor,
    10. int? heightCm,
    11. String? measurements,
    12. String? fakeTits,
    13. double? penisLength,
    14. String? circumcised,
    15. String? careerStart,
    16. String? careerEnd,
    17. String? tattoos,
    18. String? piercings,
    19. List<String> aliasList,
    20. bool favorite,
    21. String? imagePath,
    22. int sceneCount,
    23. int imageCount,
    24. int galleryCount,
    25. int groupCount,
    26. int? rating100,
    27. String? details,
    28. String? deathDate,
    29. String? hairColor,
    30. int? weight,
    31. List<String> tagIds,
    32. List<String> tagNames,
    )
)

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?>(TResult Function( String id,  String name,  String? disambiguation,  List<String> urls,  String? gender,  String? birthdate,  String? ethnicity,  String? country, @JsonKey(name: 'eye_color')  String? eyeColor, @JsonKey(name: 'height_cm')  int? heightCm,  String? measurements, @JsonKey(name: 'fake_tits')  String? fakeTits, @JsonKey(name: 'penis_length')  double? penisLength,  String? circumcised, @JsonKey(name: 'career_start')  String? careerStart, @JsonKey(name: 'career_end')  String? careerEnd,  String? tattoos,  String? piercings, @JsonKey(name: 'alias_list')  List<String> aliasList,  bool favorite, @JsonKey(name: 'image_path')  String? imagePath, @JsonKey(name: 'scene_count')  int sceneCount, @JsonKey(name: 'image_count')  int imageCount, @JsonKey(name: 'gallery_count')  int galleryCount, @JsonKey(name: 'group_count')  int groupCount,  int? rating100,  String? details, @JsonKey(name: 'death_date')  String? deathDate, @JsonKey(name: 'hair_color')  String? hairColor,  int? weight, @JsonKey(name: 'tag_ids')  List<String> tagIds, @JsonKey(name: 'tag_names')  List<String> tagNames)  $default,) {final _that = this;
switch (_that) {
case _Performer():
return $default(_that.id,_that.name,_that.disambiguation,_that.urls,_that.gender,_that.birthdate,_that.ethnicity,_that.country,_that.eyeColor,_that.heightCm,_that.measurements,_that.fakeTits,_that.penisLength,_that.circumcised,_that.careerStart,_that.careerEnd,_that.tattoos,_that.piercings,_that.aliasList,_that.favorite,_that.imagePath,_that.sceneCount,_that.imageCount,_that.galleryCount,_that.groupCount,_that.rating100,_that.details,_that.deathDate,_that.hairColor,_that.weight,_that.tagIds,_that.tagNames);case _:
  throw StateError('Unexpected subclass');

}
}