modularity_get_it 0.1.0 copy "modularity_get_it: ^0.1.0" to clipboard
modularity_get_it: ^0.1.0 copied to clipboard

GetIt adapter for Modularity framework. Provides GetItBinder implementation for seamless DI integration.

modularity_get_it #

pub package pub points

GetIt adapter for the Modularity framework. Allows using GetIt as the backing DI container.

Features #

  • GetItBinder: Implementation of ExportableBinder that delegates to GetIt
  • GetItBinderFactory: Factory to create GetIt binders with parent scope support
  • Dual Scopes: Separate private and public scopes for proper module isolation
  • Hot Reload Support: Reset and rebind without creating new instances

Installation #

dependencies:
  modularity_get_it: ^0.0.1
  modularity_core: ^0.0.1

Usage #

Basic Setup #

import 'package:modularity_core/modularity_core.dart';
import 'package:modularity_get_it/modularity_get_it.dart';

class MyModule extends Module {
  @override
  void binds(Binder binder) {
    binder.registerLazySingleton<MyService>(() => MyServiceImpl());
  }
  
  @override
  void exports(Binder binder) {
    binder.registerLazySingleton<MyService>(() => binder.get<MyService>());
  }
}

void main() async {
  final controller = ModuleController(
    MyModule(),
    binderFactory: const GetItBinderFactory(),
  );
  
  await controller.initialize({});
  
  final service = controller.binder.get<MyService>();
}

Accessing GetIt Directly #

final binder = GetItBinder();

// Access internal (private) container
final internalGetIt = binder.internalContainer;

// Access public (exported) container  
final publicGetIt = binder.publicContainer;

Debug Graph #

final binder = controller.binder as GetItBinder;
print(binder.debugGraph(includeImports: true));

API Reference #

GetItBinder #

Method Description
registerFactory<T>() Register a factory (new instance each time)
registerLazySingleton<T>() Register a lazy singleton
registerSingleton<T>() Register an eager singleton
get<T>() Get dependency (throws if not found)
tryGet<T>() Get dependency (returns null if not found)
tryGetPublic<T>() Get only from public/exported scope

GetItBinderFactory #

Creates GetItBinder instances with optional parent scope support.

const factory = GetItBinderFactory();
final binder = factory.create(); // No parent
final childBinder = factory.create(parentBinder); // With parent

License #

MIT License - see LICENSE for details.

0
likes
130
points
248
downloads

Publisher

unverified uploader

Weekly Downloads

GetIt adapter for Modularity framework. Provides GetItBinder implementation for seamless DI integration.

Repository (GitHub)
View/report issues

Topics

#dependency-injection #di #get-it #modularity

Documentation

API reference

License

MIT (license)

Dependencies

get_it, modularity_contracts

More

Packages that depend on modularity_get_it