graft
1.0.0-alpha.10, released 2 weeks ago by an unverified publisher
Self-optimizing state management and dependency injection engine for Flutter with zero code generation.
What it does
Combines structured domain models with micro-rebuild precision using register-level CPU bitmask diffing. Allows you to update mutable state via standard cascades while rebuilding only the exact UI slots that read changed properties.
AI-written summary of version 1.0.0-alpha.10, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want granular widget rebuilds without writing manual buildWhen conditions
- You prefer structured domain models over fragmented reactive primitives without needing code generation
- You need clean zero-wrapper route lifecycle dependency scoping
Skip it when
- You strictly follow immutable-only state paradigms with copyWith
- You prefer mature, stream-based architectures like BLoC or atomic providers like Riverpod
Strengths
- Zero code generation required for models
- Surgical field-level UI rebuild precision via bitmask diffing
- Lazy universal dependency injection with type-safe scopes
- Synchronous frame-0 persistence hydration
Weaknesses
- Relies on mutable state classes and cascade assignments
- Alpha stability level with potential API shifts
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 1
Add graft and optional custom_lint / graft_lint package to pubspec.yaml, and enable custom_lint in analysis_options.yaml.
class UserState extends GraftState {
String name = 'Alice';
int points = 0;
@override
GraftProps get props => propsOf(name, points);
}
class UserGraft extends Graft<UserState> {
UserGraft() : super(UserState());
void addPoint() {
state
..points += 1
..update();
}
}Alternatives
Packages that do the same job and could replace graft.
- bloc
You prefer predictable, stream-based, immutable state transitions with explicit events.
92Compare - riverpod
You prefer compile-safe global providers and immutable reactive state graphs.
99Compare - provider
You want a classic, widely adopted dependency injection and simple inheritance-based change notification system.
81Compare