lite_ref
1.0.1, released today by nosy.dev
A lightweight, no‑dependency DI library for Dart and Flutter.
WASM-ready
What it does
Provides scoped, singleton and transient references with simple override and automatic disposal support. Uses top‑level variables for fast lookups and safe error handling.
AI-written summary of version 1.0.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need a minimal DI solution without code generation.
- You want easy testing via overrides in widget sub‑trees.
- You prefer a small API surface and no extra package dependencies.
Skip it when
- You require advanced code‑generated injection (e.g., @Injectable).
- You need a large ecosystem of plugins and integrations.
Strengths
- Zero external dependencies, keeping the app size small.
- Fast lookups without hash‑maps.
- Built‑in disposal for ChangeNotifier/Disposable objects.
- Simple API that’s easy to learn.
Weaknesses
- Limited feature set compared to more mature DI containers.
- No code‑generation support for compile‑time safety.
- Smaller community and fewer third‑party extensions.
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
final settingsServiceRef = Ref.scoped((ctx) => SettingsService());
class SettingsPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final service = settingsServiceRef.of(context);
return Text(service.getThemeMode());
}
}Alternatives
Packages that do the same job and could replace lite_ref.
Works with
Packages commonly used together with lite_ref: ones it builds on, ones built on it, and its own family.