whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? relationship(
- Relationship data
- TResult? notFoundActor(
- NotFoundActor data
- TResult? 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( Relationship data)? relationship,TResult? Function( NotFoundActor data)? notFoundActor,TResult? Function( Map<String, dynamic> data)? unknown,}) {final _that = this;
switch (_that) {
case UGraphGetRelationshipsRelationshipsRelationship() when relationship != null:
return relationship(_that.data);case UGraphGetRelationshipsRelationshipsNotFoundActor() when notFoundActor != null:
return notFoundActor(_that.data);case UGraphGetRelationshipsRelationshipsUnknown() when unknown != null:
return unknown(_that.data);case _:
return null;
}
}