when<TResult extends Object?> method
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');
}
}