maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String id,
    2. String ownerId,
    3. Asset warehouse,
    4. String warehouseId,
    5. String? qrCode,
    6. @TenvioOrderStatusConverter() TenvioOrderStatus status,
    7. @TenvioDestinationTypeOrNullConverter() TenvioDestinationType? destinationType,
    8. Asset? destinationWarehouse,
    9. String? destinationWarehouseId,
    10. User? destinationUser,
    11. String? destinationUserId,
    12. TenvioUnregisteredUser? destinationUnregistered,
    13. List<String> notes,
    14. bool? requiresPhotos,
    15. bool? highPriority,
    16. List<User>? packers,
    17. List<String>? packersIds,
    18. List<TenvioItemQuantity>? itemQuantities,
    19. List<TenvioItem>? items,
    20. String? packedImage,
    21. List<TenvioPhotos>? statusPhotos,
    22. @TimestampOrNullConverter() DateTime? createdAt,
    23. @TimestampOrNullConverter() DateTime? updatedAt,
    )?, {
  2. 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();

}
}