modularity_contracts
LogoModularity

modularity_contracts#

Contracts (interfaces) for the Modularity dependency-injection framework.

This library defines the core abstractions that every Modularity package depends on: Binder, Module, BinderFactory, Configurable, ModuleInterceptor, and the exception hierarchy.

Concrete implementations live in separate packages such as modularity_core and modularity_injectable.

import 'package:modularity_contracts/modularity_contracts.dart';

class AuthModule extends Module {
  @override
  void binds(Binder i) {
    i.registerLazySingleton<AuthService>(() => AuthServiceImpl());
  }
}

Classes#

ClassDescription
Binder Core interface for registering and resolving dependencies.
BinderFactory Factory for creating Binder instances.
Configurable<T> Interface for modules that require runtime configuration before initialization.
DisposableBinder Contract for a Binder that supports explicit disposal of resources.
ExportableBinder Extended Binder that separates registrations into private and public (exported) scopes.
ModularityLogger Contract for logging framework events.
Module Base contract for a module in the Modularity framework.
ModuleInterceptor Observer for Module lifecycle events.
ModuleRetentionContext Context payload used to derive a deterministic retention identity for a module instance.
RegistrationAwareBinder Contract for a Binder that can switch its RegistrationStrategy at runtime.

Exceptions#

ExceptionDescription
CircularDependencyException Thrown when a circular dependency is detected in the module import graph.
DependencyNotFoundException Thrown when a requested dependency cannot be found in the binder chain.
ModularityException Base exception for all Modularity framework errors.
ModuleConfigurationException Thrown when a module is incorrectly configured.
ModuleLifecycleException Thrown when a module lifecycle operation fails.

Enums#

EnumDescription
LogLevel Severity levels for framework log messages.
ModuleRetentionPolicy Defines how a ModuleScope manages the lifetime of a module relative to navigation and widget lifecycle events.
ModuleStatus Lifecycle statuses of a module.
RegistrationStrategy Defines the strategy for handling duplicate dependency registrations.

Mixins#

MixinDescription
RetentionIdentityProvider Optional mixin for modules that compute their own retention key.