whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? $default(
- String $type,
- String source,
- int id,
- @JsonKey.new(toJson: iso8601) DateTime createdAt,
- String createdBy,
- String type,
- String? subject,
- int? reportId,
- int? actionEventId,
- @ModEventViewConverter() ModEventView? event,
- @ReportActivityViewConverter() ReportActivityView? activity,
- Map<
String, dynamic> ? $unknown,
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( String $type, String source, int id, @JsonKey(toJson: iso8601) DateTime createdAt, String createdBy, String type, String? subject, int? reportId, int? actionEventId, @ModEventViewConverter() ModEventView? event, @ReportActivityViewConverter() ReportActivityView? activity, Map<String, dynamic>? $unknown)? $default,) {final _that = this;
switch (_that) {
case _ActivityRow() when $default != null:
return $default(_that.$type,_that.source,_that.id,_that.createdAt,_that.createdBy,_that.type,_that.subject,_that.reportId,_that.actionEventId,_that.event,_that.activity,_that.$unknown);case _:
return null;
}
}