toor
2.0.0, released 3 years ago by fperson.dev
Compile-time safe and easy to manage service locators for Dart and Flutter.
What it does
Toor provides compile-time safe service location for Dart and Flutter. It supports factories, lazy singletons, mutable lazy singletons, async factories, and factories with parameters without requiring code generation.
AI-written summary of version 2.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want compile-time safe dependency injection without setting up code generation.
- You need support for parameterized factories, async factories, and lazy singletons.
- You want to easily override or reset dependencies during testing.
Skip it when
- You prefer annotation-driven dependency injection frameworks like get_it with injectable.
- You require complex hierarchical module dependency graphs.
Strengths
- Compile-time safety for service locators.
- Supports multiple instances of Toor for isolated domains or testing.
- No code generation setup required.
Weaknesses
- Manual wiring of dependencies.
- Lacks advanced dependency graph validation tools found in codegen-based DI.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
final toor = Toor.instance;
final httpClientSingleton = toor.registerLazySingleton<IHttpClient>(
DioHttpClientImpl.new,
);
final authRepositoryFactory = toor.registerFactory<IAuthRepository>(
() => AuthRepositoryImpl(httpClient: httpClientSingleton()),
);Alternatives
Packages that do the same job and could replace toor.
- get_it
A fast, type-safe service locator for Dart and Flutter without BuildContext or code generation.
89Compare - yx_scope
A compile-safe dependency injection framework with advanced scoping capabilities.
84Compare - cobalt
Dependency injection for Dart and Flutter with scopes, async ordering, and tests.
64Compare - flutter_koin
A lightweight dependency injection library for Flutter with code generation and scopes.
63Compare