when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. String id,
    2. String name,
    3. String description,
    4. ChannelImportance importance,
    5. bool playSound,
    6. bool enableVibration,
    7. bool showBadge,
    8. String? sound,
    9. String? categoryId,
    )
)

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 name,  String description,  ChannelImportance importance,  bool playSound,  bool enableVibration,  bool showBadge,  String? sound,  String? categoryId)  $default,) {final _that = this;
switch (_that) {
case _NotificationChannel():
return $default(_that.id,_that.name,_that.description,_that.importance,_that.playSound,_that.enableVibration,_that.showBadge,_that.sound,_that.categoryId);case _:
  throw StateError('Unexpected subclass');

}
}