whenOrNull<TResult extends Object?> method
TResult?
whenOrNull<TResult extends Object?>(
- TResult? $default(
- String id,
- AtsNsStatus status,
- bool? receive90Days,
- AtsNsProjectId? projectId,
- String? certificate,
- String? certificatePassword,
- String cnpj,
- String? inscriptionId,
- String? businessName,
- String? companyName,
- AtsIcmsType? icmsType,
- List<
String> ? emails, - List<
String> ? phoneNumbers, - List<
AtsNsAddress> ? addresses, - DateTime? expirationDate,
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 id, @AtsNsStatusConverter() AtsNsStatus status, bool? receive90Days, @AtsNsProjectIdOrNullConverter() AtsNsProjectId? projectId, String? certificate, String? certificatePassword, String cnpj, String? inscriptionId, String? businessName, String? companyName, @AtsIcmsTypeOrNullConverter() AtsIcmsType? icmsType, List<String>? emails, List<String>? phoneNumbers, List<AtsNsAddress>? addresses, @JsonKey(name: 'expirationDateUnix')@TimestampOrNullConverter() DateTime? expirationDate)? $default,) {final _that = this;
switch (_that) {
case _AtsNsLicense() when $default != null:
return $default(_that.id,_that.status,_that.receive90Days,_that.projectId,_that.certificate,_that.certificatePassword,_that.cnpj,_that.inscriptionId,_that.businessName,_that.companyName,_that.icmsType,_that.emails,_that.phoneNumbers,_that.addresses,_that.expirationDate);case _:
return null;
}
}