when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. String $type,
    2. String? appealSubmittedBy,
    3. String? appealActionType,
    4. int? appealActionId,
    5. String? appealLabel,
    6. String? comment,
    7. bool? isReporterMuted,
    8. @ReasonTypeConverter() ReasonType reportType,
    9. Map<String, dynamic>? $unknown,
    )
)

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 $type,  String? appealSubmittedBy,  String? appealActionType,  int? appealActionId,  String? appealLabel,  String? comment,  bool? isReporterMuted, @ReasonTypeConverter()  ReasonType reportType,  Map<String, dynamic>? $unknown)  $default,) {final _that = this;
switch (_that) {
case _ModEventReport():
return $default(_that.$type,_that.appealSubmittedBy,_that.appealActionType,_that.appealActionId,_that.appealLabel,_that.comment,_that.isReporterMuted,_that.reportType,_that.$unknown);case _:
  throw StateError('Unexpected subclass');

}
}