Named class

Marks a class as a bean, or selects a bean at an injection point; the standard Java (JSR-330) name for Component and Qualifier.

On a class it behaves like @Component, on an injection point like @Qualifier. It exists for code ported from Java that uses @Named.

@Named('fastGateway')
class FastGateway implements PaymentGateway { ... }

// Checkout always pays through the fast gateway.
@Named()
class Checkout {
  Checkout(@Named('fastGateway') this.gateway);
  final PaymentGateway gateway;
}

Spring (Java):

@Named("fastGateway")
class FastGateway implements PaymentGateway { ... }

@Named
class Checkout {
  @Inject
  Checkout(@Named("fastGateway") PaymentGateway gateway) { ... }
}
Inheritance

Constructors

Named([String? name])
Declares the bean, or selects one; name is the bean name or qualifier.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
name → String?
The bean name; null gives the class name in lowerCamelCase.
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