when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. String id,
    2. String orgId,
    3. String type,
    4. String title,
    5. String body,
    6. Map<String, dynamic> metadata,
    7. DateTime? readAt,
    8. DateTime createdAt,
    )
)

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 orgId,  String type,  String title,  String body,  Map<String, dynamic> metadata,  DateTime? readAt,  DateTime createdAt)  $default,) {final _that = this;
switch (_that) {
case _OrgNotification():
return $default(_that.id,_that.orgId,_that.type,_that.title,_that.body,_that.metadata,_that.readAt,_that.createdAt);case _:
  throw StateError('Unexpected subclass');

}
}