EventListener class final

Annotation to mark a method that should run when the application is listening to a specific type of ApplicationEvent.

This is typically used to register event listeners in the application context, allowing them to receive and process events published by the framework or custom domain events.

The only acceptable method signatures are:

  • No-Arg: The method should not accept any arguments.
  • One-Arg: The method should accept a single argument of type ApplicationEvent.

Example

class MyApp {
  @EventListener()
  void handleEvent(ApplicationEvent event) {
    print("Event received: $event");
  }

  @EventListener(EventType<ContextRefreshedEvent>('user_package'))
  void handleContextRefreshedEvent() {
    print("Context refreshed");
  }
}
Inheritance
Mixed-in types
Annotations
  • @Target.new({TargetKind.method})

Constructors

EventListener([EventType<ApplicationEvent>? event])
Annotation to mark a method that should run when the application is listening to a specific type of ApplicationEvent.
const

Properties

annotationType Type
Returns the annotation _type of this annotation.
no setteroverride
event EventType<ApplicationEvent>?
The type of ApplicationEvent to listen to.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

equalizedProperties() List<Object?>
Mixin-style contract for value-based equality, hashCode, and toString.
override
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
A string representation of this object.
inherited

Operators

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