when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. String? format,
    2. int? width,
    3. int? height,
    4. String? videoCodec,
    5. String? audioCodec,
    6. int? bitRate,
    7. double? duration,
    8. double? frameRate,
    )
)

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? format,  int? width,  int? height, @JsonKey(name: 'video_codec')  String? videoCodec, @JsonKey(name: 'audio_codec')  String? audioCodec, @JsonKey(name: 'bit_rate')  int? bitRate,  double? duration, @JsonKey(name: 'frame_rate')  double? frameRate)  $default,) {final _that = this;
switch (_that) {
case _SceneFile():
return $default(_that.format,_that.width,_that.height,_that.videoCodec,_that.audioCodec,_that.bitRate,_that.duration,_that.frameRate);case _:
  throw StateError('Unexpected subclass');

}
}