stark
4.0.0, released 3 years ago by softarch.dev
A lightweight, reflection‑free DI framework for Dart and Flutter.
WASM-ready
What it does
Stark lets you register singletons and factories, retrieve them anywhere, and optionally scope them to widget lifecycles. It supports named injections, dynamic parameters, and disposable objects.
AI-written summary of version 4.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need simple DI without code generation or reflection
- You want scoped lifetimes tied to widget state
- You prefer a small API surface over feature‑rich containers
Skip it when
- You require compile‑time safety via code‑gen (e.g., injectable)
- You need advanced features like lazy async factories or multi‑binding
- You already use a DI solution integrated with other libraries
Strengths
- No reflection – works on all Flutter platforms
- Supports scoped lifetimes and disposable cleanup
- Simple, easy‑to‑read API
Weaknesses
- No compile‑time checks, runtime errors if types mismatch
- Limited advanced features compared to larger containers
- Manual registration can become verbose in large apps
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
import 'package:stark/stark.dart';
final appModule = {
single((i) => Api()),
factory((i) => UseCase(i.get()))
};
void main(){
Stark.init([appModule]);
final useCase = Stark.get<UseCase>();
}Alternatives
Packages that do the same job and could replace stark.