AppModule class abstract

Base interface for all modules in the Air Framework.

Provides a complete lifecycle for modules:

  1. onBind(AirDI di) - Register dependencies (DI)
  2. onInit(AirDI di) - Async initialization logic
  3. onDispose(AirDI di) - Cleanup when module is unregistered

Example:

class MyModule extends AppModule {
  @override
  String get id => 'my_module';

  @override
  String get name => 'My Module';

  @override
  void onBind(AirDI di) {
    di.register<MyService>(MyService());
  }

  @override
  Future<void> onInit(AirDI di) async {
    final service = di.get<MyService>();
    await service.loadInitialData();
  }

  @override
  Future<void> onDispose(AirDI di) async {
    final service = di.get<MyService>();
    await service.cleanup();
  }
}

Constructors

AppModule()

Properties

color Color
Primary color associated with the module for UI branding.
no setter
dependencies List<String>
List of mandatory module dependencies.
no setter
hashCode int
The hash code for this object.
no setterinherited
icon IconData
Icon representing the module in the application UI.
no setter
id String
Unique identifier for the module (e.g., 'auth', 'counter'). Used for dependency resolution and event bus filtering.
no setter
initialRoute String
The route path where the module starts (e.g., '/counter').
no setter
name String
Human-readable name of the module (e.g., 'Authentication', 'Counter'). Typically used in UI menus or debug logs.
no setter
optionalDependencies List<String>
List of optional module dependencies.
no setter
routes List<AirRoute>
List of AirRoute definitions provided by this module. All routes listed here will be registered in the global router.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state ModuleLifecycleState
Current lifecycle state of the module
no setter
version String
Version of the module following Semantic Versioning (semver). Defaults to '1.0.0'.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onBind(AirDI di) → void
Synchronous configuration and dependency registration.
onDispose(AirDI di) Future<void>
Resource cleanup when the module is being removed.
onError(Object error, StackTrace stackTrace) → void
Global error handler for this module's lifecycle.
onInit(AirDI di) Future<void>
Asynchronous initialization logic for the module.
toString() String
A string representation of this object.
inherited

Operators

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