yx_scope
1.2.2, released 6 weeks ago by dev.go.yandex
A compile-safe dependency injection framework with advanced scoping capabilities.
What it does
yx_scope is a pure Dart dependency injection framework that allows declaring dependency trees and scopes without code generation. It uses ScopeContainers and ScopeHolders to manage the lifecycle of isolated sets of dependencies with compile-safe checks.
AI-written summary of version 1.2.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want compile-safe dependency injection without relying on code generation.
- Your application requires explicit and nested scoping of dependencies.
- You want DI containers to be driven by application logic rather than UI widget creation.
Skip it when
- You prefer a traditional service locator pattern like get_it.
- You want automated registration via annotations and builders.
Strengths
- Compile-safe access to dependencies and existence of active scopes
- No code generation required
- Supports asynchronous dependencies and custom scope nesting
Weaknesses
- Requires manual declaration of dependency containers and scopes
- Less community-standard compared to global service locators
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
Pure Dart package, add to pubspec.yaml and create scope container classes.
class AppScopeContainer extends ScopeContainer {
late final routerDelegateDep = dep(() => AppRouterDelegate());
}
class AppScopeHolder extends ScopeHolder<AppScopeContainer> {
@override
AppScopeContainer createContainer() => AppScopeContainer();
}Alternatives
Packages that do the same job and could replace yx_scope.
- get_it
If you prefer a global service locator approach instead of declarative scope containers.
89Compare - injectable
If you prefer code-generation based dependency injection with annotations.
78Compare
Works with
Packages commonly used together with yx_scope: ones it builds on, ones built on it, and its own family.