AirAdapter class abstract

Base interface for all Adapters in the Air Framework.

An Adapter encapsulates an external integration (HTTP client, error tracking, analytics, local storage, etc.) without the overhead of a full AppModule.

Unlike modules, adapters do not have routes, UI (icon/color), or navigation. They focus exclusively on registering and managing infrastructure services.

Adapters are registered before modules so that modules can depend on adapter-provided services through the shared AirDI container.

Lifecycle

  1. onBind(AirDI di) — Register dependencies synchronously
  2. onInit(AirDI di) — Async initialization (connections, configs)
  3. onDispose(AirDI di) — Cleanup resources

Example

class DioAdapter extends AirAdapter {
  final String baseUrl;
  DioAdapter({required this.baseUrl});

  @override
  String get id => 'dio';

  @override
  String get name => 'Dio HTTP Client';

  @override
  void onBind(AirDI di) {
    di.registerLazySingleton<HttpClient>(() => DioHttpClient(baseUrl));
  }
}

Community Publishing Convention

Adapter packages should follow the naming pattern: air_adapter_<service>

Package Description
air_adapter_dio HTTP client with Dio
air_adapter_sentry Error tracking
air_adapter_firebase Firebase integration
air_adapter_hive Local storage

Constructors

AirAdapter()

Properties

dependencies → List<String>
List of other adapter IDs that this adapter depends on.
no setter
hashCode → int
The hash code for this object.
no setterinherited
id → String
Unique identifier for the adapter (e.g., 'dio', 'sentry'). Used for dependency resolution and debugging.
no setter
name → String
Human-readable name of the adapter (e.g., 'Dio HTTP Client'). Used in DevTools and debug logs.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
state → AdapterLifecycleState
Current lifecycle state of the adapter
no setter
version → String
Version of the adapter 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 adapter is being removed.
onError(Object error, StackTrace stackTrace) → void
Global error handler for this adapter's lifecycle.
onInit(AirDI di) → Future<void>
Asynchronous initialization logic for the adapter.
toString() → String
A string representation of this object.
inherited

Operators

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