whenOrNull<TResult extends Object?> method
TResult?
whenOrNull<TResult extends Object?>(
- TResult? $default()?
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( int? id, String? name, String? location, double? latitude, double? longitude, int? businessUnitId, int? depotTypeId, int? depotStatus, BusinessUnit? businessUnit, DepotType? depotType, InternalArea? internalArea, int? internalAreaId, DateTime? createdDate, String? cluster, String? internalRegion)? $default,) {final _that = this;
switch (_that) {
case _Depot() when $default != null:
return $default(_that.id,_that.name,_that.location,_that.latitude,_that.longitude,_that.businessUnitId,_that.depotTypeId,_that.depotStatus,_that.businessUnit,_that.depotType,_that.internalArea,_that.internalAreaId,_that.createdDate,_that.cluster,_that.internalRegion);case _:
return null;
}
}