mapOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? blocking(
- UModerationCauseBlocking value
- TResult? blockedBy(
- UModerationCauseBlockedBy value
- TResult? blockOther(
- UModerationCauseBlockOther value
- TResult? label(
- UModerationCauseLabel value
- TResult? muted(
- UModerationCauseMuted value
- TResult? muteWord(
- UModerationCauseMuteWord value
A variant of map
that fallback to returning null
.
It is equivalent to doing:
switch (sealedClass) {
case final Subclass value:
return ...;
case _:
return null;
}
Implementation
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( UModerationCauseBlocking value)? blocking,TResult? Function( UModerationCauseBlockedBy value)? blockedBy,TResult? Function( UModerationCauseBlockOther value)? blockOther,TResult? Function( UModerationCauseLabel value)? label,TResult? Function( UModerationCauseMuted value)? muted,TResult? Function( UModerationCauseMuteWord value)? muteWord,TResult? Function( UModerationCauseHidden value)? hidden,}){
final _that = this;
switch (_that) {
case UModerationCauseBlocking() when blocking != null:
return blocking(_that);case UModerationCauseBlockedBy() when blockedBy != null:
return blockedBy(_that);case UModerationCauseBlockOther() when blockOther != null:
return blockOther(_that);case UModerationCauseLabel() when label != null:
return label(_that);case UModerationCauseMuted() when muted != null:
return muted(_that);case UModerationCauseMuteWord() when muteWord != null:
return muteWord(_that);case UModerationCauseHidden() when hidden != null:
return hidden(_that);case _:
return null;
}
}