whenOrNull<TResult extends Object?> method

  1. @optionalTypeArgs
TResult? whenOrNull<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 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? 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() when $default != null:
return $default(_that.format,_that.width,_that.height,_that.videoCodec,_that.audioCodec,_that.bitRate,_that.duration,_that.frameRate);case _:
  return null;

}
}