# Autowired constructor

const Autowired()

Autowired annotation for dependency injection

This annotation marks a field, setter, or constructor for automatic dependency injection.

Example Usage:

    @Service()
    class OrderService {
      @Autowired()
      late UserService userService;

      @Autowired()
      late PaymentService paymentService;

      @Autowired()
      late InventoryService? inventoryService;

      // Constructor injection (preferred)
      OrderService();

      Future<Order> createOrder(CreateOrderRequest request) async {
        final user = await userService.findById(request.userId);
        await inventoryService.reserveItems(request.items);
        final payment = await paymentService.processPayment(request.payment);

        return Order(
          id: generateId(),
          userId: user.id,
          items: request.items,
          payment: payment,
          createdAt: DateTime.now(),
        );
      }
    }

## Implementation

    const Autowired();