Value class

Value annotation for property injection

This annotation injects property values into fields and parameters.

Example Usage:

PodExpression<String> expr = (context) {
  return StandardPodCache("Hello, ${context.getPod("userName")}", "dart.core.String");
};

@Component()
class DatabaseService {
  @Value('#{database.url}')
  late final String databaseUrl;
  
  @Value('#{database.timeout:30}') // Default value 30
  late final int timeout;

  @Value('@{lifecycleProcessor}') // Reference to a pod
  late final LifecycleProcessor lifecycleProcessor;
  
  @Value("&{systemProperties['user.home']}") // Pod expression
  late final String userHome;

  @Value(CustomPodExpression<String>()) // Custom pod expression
  late final String customValue;
}

@Configuration()
class AppConfig {
  @Pod()
  DataSource dataSource(
    @Value('#{database.url}') String url,
    @Value('#{database.username}') String username,
    @Value('#{database.password}') String password
  ) {
    return DataSource(url: url, username: username, password: password);
  }
}
Inheritance
Annotations
  • @Target.new({TargetKind.field, TargetKind.parameter})

Constructors

Value(Object value)
Value annotation for property injection
const

Properties

annotationType → Type
Returns the annotation _type of this annotation.
no setteroverride
hashCode → int
Returns a hash code consistent with equality definition.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
value → Object
Property expression
final

Methods

equals(Object other) → bool
Checks whether the given object is logically equivalent to this annotation.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
Returns a string representation of this annotation.
override

Operators

operator ==(Object other) → bool
Checks if this annotation is equal to another object.
inherited