maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. bool enabled,
    2. double volume,
    3. bool messageSent,
    4. bool messageReceived,
    5. bool chatOpened,
    6. bool chatClosed,
    7. bool error,
    8. bool buttonClick,
    9. bool notification,
    10. String? messageSentSoundUrl,
    11. String? messageReceivedSoundUrl,
    12. String? notificationSoundUrl,
    13. String? errorSoundUrl,
    )?, {
  2. required TResult orElse(),
})

A variant of when that fallback to an orElse callback.

It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case _:
    return orElse();
}

Implementation

@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool enabled,  double volume,  bool messageSent,  bool messageReceived,  bool chatOpened,  bool chatClosed,  bool error,  bool buttonClick,  bool notification,  String? messageSentSoundUrl,  String? messageReceivedSoundUrl,  String? notificationSoundUrl,  String? errorSoundUrl)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _SoundConfiguration() when $default != null:
return $default(_that.enabled,_that.volume,_that.messageSent,_that.messageReceived,_that.chatOpened,_that.chatClosed,_that.error,_that.buttonClick,_that.notification,_that.messageSentSoundUrl,_that.messageReceivedSoundUrl,_that.notificationSoundUrl,_that.errorSoundUrl);case _:
  return orElse();

}
}