maybeWhen<TResult extends Object?> method
TResult
maybeWhen<TResult extends Object?>(
- TResult $default(
- String id,
- String ownerId,
- Asset warehouse,
- String warehouseId,
- String? qrCode,
- @TenvioOrderStatusConverter() TenvioOrderStatus status,
- @TenvioDestinationTypeOrNullConverter() TenvioDestinationType? destinationType,
- Asset? destinationWarehouse,
- String? destinationWarehouseId,
- User? destinationUser,
- String? destinationUserId,
- TenvioUnregisteredUser? destinationUnregistered,
- List<
String> notes, - bool? requiresPhotos,
- bool? highPriority,
- List<
User> ? packers, - List<
String> ? packersIds, - List<
TenvioItemQuantity> ? itemQuantities, - List<
TenvioItem> ? items, - String? packedImage,
- List<
TenvioPhotos> ? statusPhotos, - @TimestampOrNullConverter() DateTime? createdAt,
- @TimestampOrNullConverter() DateTime? updatedAt,
- required TResult orElse(),
A variant of when that fallback to an orElse callback.
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case _:
return orElse();
}
Implementation
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String ownerId, Asset warehouse, String warehouseId, String? qrCode, @TenvioOrderStatusConverter() TenvioOrderStatus status, @TenvioDestinationTypeOrNullConverter() TenvioDestinationType? destinationType, Asset? destinationWarehouse, String? destinationWarehouseId, User? destinationUser, String? destinationUserId, TenvioUnregisteredUser? destinationUnregistered, List<String> notes, bool? requiresPhotos, bool? highPriority, List<User>? packers, List<String>? packersIds, List<TenvioItemQuantity>? itemQuantities, List<TenvioItem>? items, String? packedImage, List<TenvioPhotos>? statusPhotos, @TimestampOrNullConverter() DateTime? createdAt, @TimestampOrNullConverter() DateTime? updatedAt)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _TenvioOrder() when $default != null:
return $default(_that.id,_that.ownerId,_that.warehouse,_that.warehouseId,_that.qrCode,_that.status,_that.destinationType,_that.destinationWarehouse,_that.destinationWarehouseId,_that.destinationUser,_that.destinationUserId,_that.destinationUnregistered,_that.notes,_that.requiresPhotos,_that.highPriority,_that.packers,_that.packersIds,_that.itemQuantities,_that.items,_that.packedImage,_that.statusPhotos,_that.createdAt,_that.updatedAt);case _:
return orElse();
}
}