Skip to content
modularity_contractsClassesmodularity_contracts

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.

dart
import 'package:modularity_contracts/modularity_contracts.dart';

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

Classes

ClassDescription
BinderCore interface for registering and resolving dependencies.
BinderFactoryFactory for creating Binder instances.
Configurable<T>Interface for modules that require runtime configuration before initialization.
DisposableBinderContract for a Binder that supports explicit disposal of resources.
ExportableBinderExtended Binder that separates registrations into private and public (exported) scopes.
ModularityLoggerContract for logging framework events.
ModuleBase contract for a module in the Modularity framework.
ModuleInterceptorObserver for Module lifecycle events.
ModuleRetentionContextContext payload used to derive a deterministic retention identity for a module instance.
RegistrationAwareBinderContract for a Binder that can switch its RegistrationStrategy at runtime.

Exceptions

ExceptionDescription
CircularDependencyExceptionThrown when a circular dependency is detected in the module import graph.
DependencyNotFoundExceptionThrown when a requested dependency cannot be found in the binder chain.
ModularityExceptionBase exception for all Modularity framework errors.
ModuleConfigurationExceptionThrown when a module is incorrectly configured.
ModuleLifecycleExceptionThrown when a module lifecycle operation fails.

Enums

EnumDescription
LogLevelSeverity levels for framework log messages.
ModuleRetentionPolicyDefines how a ModuleScope manages the lifetime of a module relative to navigation and widget lifecycle events.
ModuleStatusLifecycle statuses of a module.
RegistrationStrategyDefines the strategy for handling duplicate dependency registrations.

Mixins

MixinDescription
RetentionIdentityProviderOptional mixin for modules that compute their own retention key.