when<TResult extends Object?> method
TResult
when<TResult extends Object?>(
- TResult $default(
- int id,
- @JsonKey.new(name: 'commercial_id') int commercialId,
- String name,
- String? description,
- @JsonKey.new(name: 'max_people') int maxPeople,
- @JsonKey.new(name: 'slot_interval') int slotInterval,
- @JsonKey.new(name: 'interval_price') List<
IsibookIntervalPrice> intervalPrice, - List images,
- @JsonKey.new(name: 'meta_value') List metaValue,
- @JsonKey.new(name: 'deleted_at') @TimestampConverter() Jiffy? deletedAt,
- @JsonKey.new(name: 'created_at') @TimestampConverter() Jiffy createdAt,
- @JsonKey.new(name: 'updated_at') @TimestampConverter() Jiffy updatedAt,
- List tags,
- @JsonKey.new(name: 'min_number_slot_reserved') int minNumberSlotReserved,
- @JsonKey.new(name: 'max_number_slot_reserved') int maxNumberSlotReserved,
- @JsonKey.new(name: 'spaces') List<
int> spaces, - @JsonKey.new(name: 'order_column') int orderColumn,
- List<
int> extras, - @JsonKey.new(name: 'can_pay_with_points') bool canPayWithPoints,
- @JsonKey.new(name: 'is_discount_active') bool isDiscountActive,
- String? color,
- @JsonKey.new(name: 'images_url') List imagesUrl,
- @JsonKey.new(name: 'isibook_space_time_slots') List<
IsibookSpaceTimeSlot> timeSlots,
A switch-like method, using callbacks.
As opposed to map, this offers destructuring.
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case Subclass2(:final field2):
return ...;
}
Implementation
@optionalTypeArgs
TResult when<TResult extends Object?>(
TResult Function(
int id,
@JsonKey(name: 'commercial_id') int commercialId,
String name,
String? description,
@JsonKey(name: 'max_people') int maxPeople,
@JsonKey(name: 'slot_interval') int slotInterval,
@JsonKey(name: 'interval_price')
List<IsibookIntervalPrice> intervalPrice,
List<dynamic> images,
@JsonKey(name: 'meta_value') List<dynamic> metaValue,
@JsonKey(name: 'deleted_at') @TimestampConverter() Jiffy? deletedAt,
@JsonKey(name: 'created_at') @TimestampConverter() Jiffy createdAt,
@JsonKey(name: 'updated_at') @TimestampConverter() Jiffy updatedAt,
List<dynamic> tags,
@JsonKey(name: 'min_number_slot_reserved')
int minNumberSlotReserved,
@JsonKey(name: 'max_number_slot_reserved')
int maxNumberSlotReserved,
@JsonKey(name: 'spaces') List<int> spaces,
@JsonKey(name: 'order_column') int orderColumn,
List<int> extras,
@JsonKey(name: 'can_pay_with_points') bool canPayWithPoints,
@JsonKey(name: 'is_discount_active') bool isDiscountActive,
String? color,
@JsonKey(name: 'images_url') List<dynamic> imagesUrl,
@JsonKey(name: 'isibook_space_time_slots')
List<IsibookSpaceTimeSlot> timeSlots)
$default,
) {
final _that = this;
switch (_that) {
case _IsibookSpace():
return $default(
_that.id,
_that.commercialId,
_that.name,
_that.description,
_that.maxPeople,
_that.slotInterval,
_that.intervalPrice,
_that.images,
_that.metaValue,
_that.deletedAt,
_that.createdAt,
_that.updatedAt,
_that.tags,
_that.minNumberSlotReserved,
_that.maxNumberSlotReserved,
_that.spaces,
_that.orderColumn,
_that.extras,
_that.canPayWithPoints,
_that.isDiscountActive,
_that.color,
_that.imagesUrl,
_that.timeSlots);
}
}