Autowired class

Autowired annotation for automatic dependency injection

Marks a field, setter method, or constructor parameter for automatic dependency injection by the Dire DI container.

Example:

@Service()
class UserService {
  @Autowired()
  late UserRepository userRepository;

  @Autowired()
  late Logger logger;

  // Constructor injection
  UserService(@Autowired() this.emailService);

  final EmailService emailService;
}

Constructors

Autowired({bool required = true})
const

Properties

hashCode int
The hash code for this object.
no setterinherited
required bool
Whether the dependency is required (default: true) If false and no bean is found, null will be injected
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited