flutter_injections
1.3.0, released 6 days ago by gabul.dev
A lightweight DI package for Flutter providing context‑free, module‑based dependency management.
WASM-ready
What it does
It lets you register dependencies in a widget tree and retrieve them anywhere without using BuildContext. Modules can group related injections and objects are auto‑disposed when the widget is removed.
AI-written summary of version 1.1.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want context‑free dependency lookup in Flutter apps
- You need module‑scoped injections for feature‑based architecture
- You prefer a simple, runtime‑only API with auto‑dispose
Skip it when
- You require compile‑time safety or code‑generation support
- You need a large ecosystem of plugins and community tooling
- You already use a different DI solution with tighter integration
Strengths
- Fast lookup using a search‑tree
- Supports module‑level injection groups
- Automatic disposal of objects
Weaknesses
- No code‑generation or compile‑time checks
- Smaller community compared to alternatives
- Limited advanced features (scoping, lazy singletons)
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
class YourPageInjections extends StatelessWidget {
const YourPageInjections({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return FlutterInjectionsWidget(
injections: [
Inject<YourRepository>((i) => YourRepository(client: i.find<Dio>())),
Inject<YourController>((i) => YourController(repository: i.find<YourRepository>())),
],
builder: (_) => const YourPage(),
);
}
}Alternatives
Packages that do the same job and could replace flutter_injections.