property_change_notifier
0.5.0, released 2 years ago by martinrybak.com
A drop-in ChangeNotifier replacement for observing specific model properties.
What it does
Extends ChangeNotifier to allow notifying listeners about specific property changes instead of an all-or-none approach. Provides PropertyChangeProvider and PropertyChangeConsumer widgets to rebuild descendants only when specific properties change.
AI-written summary of version 0.5.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want a granular alternative to standard ChangeNotifier without learning a massive state management framework.
- Your models are relatively simple and you want widgets to rebuild only when specific properties change.
Skip it when
- You are already using a comprehensive state management framework like Riverpod or BLoC.
- You need complex dependency injection and stream-based business logic separation.
Strengths
- 100% backwards compatible with existing ChangeNotifier code.
- Supports fine-grained rebuilds based on specific property names.
- Includes helper widgets like PropertyChangeProvider and PropertyChangeConsumer.
Weaknesses
- Relies on string literals or enums for property names, which can be less robust than fully typed states.
- Not suitable for large-scale architectures requiring strict unidirectional data flow.
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
class MyModel with PropertyChangeNotifier<String> {
int _foo = 0;
int get foo => _foo;
set foo(int value) {
_foo = value;
notifyListeners('foo');
}
}Alternatives
Packages that do the same job and could replace property_change_notifier.
- provider
If you want standard inherited widget-based dependency injection and state management without property-level granularity.
81Compare - flutter_riverpod
If you want a robust, compile-safe, modern state management solution that avoids BuildContext.
93Compare - flutter_bloc
If you prefer a predictable, event-driven state management pattern.
86Compare