whenOrNull<TResult extends Object?> method
TResult?
whenOrNull<TResult extends Object?>(
- TResult? $default(
- @JsonKey.new(name: 'current_page') int currentPage,
- List<
IsibookMyReservation> data, - @JsonKey.new(name: 'first_page_url') String? firstPageUrl,
- int? from,
- @JsonKey.new(name: 'last_page') int? lastPage,
- @JsonKey.new(name: 'last_page_url') String? lastPageUrl,
- List<
IsibookReservationLink> links, - @JsonKey.new(name: 'next_page_url') String? nextPageUrl,
- String path,
- @JsonKey.new(name: 'per_page') int perPage,
- @JsonKey.new(name: 'prev_page_url') String? prevPageUrl,
- int? to,
- int? total,
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(
@JsonKey(name: 'current_page') int currentPage,
List<IsibookMyReservation> data,
@JsonKey(name: 'first_page_url') String? firstPageUrl,
int? from,
@JsonKey(name: 'last_page') int? lastPage,
@JsonKey(name: 'last_page_url') String? lastPageUrl,
List<IsibookReservationLink> links,
@JsonKey(name: 'next_page_url') String? nextPageUrl,
String path,
@JsonKey(name: 'per_page') int perPage,
@JsonKey(name: 'prev_page_url') String? prevPageUrl,
int? to,
int? total)?
$default,
) {
final _that = this;
switch (_that) {
case _IsibookReservationsPage() when $default != null:
return $default(
_that.currentPage,
_that.data,
_that.firstPageUrl,
_that.from,
_that.lastPage,
_that.lastPageUrl,
_that.links,
_that.nextPageUrl,
_that.path,
_that.perPage,
_that.prevPageUrl,
_that.to,
_that.total);
case _:
return null;
}
}