whenOrNull<TResult extends Object?> method
TResult?
whenOrNull<TResult extends Object?>()
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( 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,) {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 null;
}
}