mapOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? create(
- URepoApplyWritesWritesCreate value
- TResult? update(
- URepoApplyWritesWritesUpdate value
- TResult? delete(
- URepoApplyWritesWritesDelete value
- TResult? unknown(
- URepoApplyWritesWritesUnknown 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( URepoApplyWritesWritesCreate value)? create,TResult? Function( URepoApplyWritesWritesUpdate value)? update,TResult? Function( URepoApplyWritesWritesDelete value)? delete,TResult? Function( URepoApplyWritesWritesUnknown value)? unknown,}){
final _that = this;
switch (_that) {
case URepoApplyWritesWritesCreate() when create != null:
return create(_that);case URepoApplyWritesWritesUpdate() when update != null:
return update(_that);case URepoApplyWritesWritesDelete() when delete != null:
return delete(_that);case URepoApplyWritesWritesUnknown() when unknown != null:
return unknown(_that);case _:
return null;
}
}