Inject class

Asks the container to inject a field, setter, method or constructor; the standard Java (JSR-330) name for Autowired.

It behaves like @Autowired(). It exists so that code ported from Java that uses @Inject reads the same.

@Named()
class Checkout {
  @Inject()
  late final PaymentGateway gateway;
}

Spring (Java):

@Named
class Checkout {
  @Inject PaymentGateway gateway;
}
Inheritance

Constructors

Inject()
Marks the injection point.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
required → bool
On a constructor, false makes it one of several candidates: the container calls the one with the most parameters it can satisfy. On fields, setters and methods a nullable type makes a dependency optional instead (required: false there fails the build).
finalinherited
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