state_lifecycle_observer 0.1.0
state_lifecycle_observer: ^0.1.0 copied to clipboard
A reusable Flutter state observer pattern implementation.
0.1.0 #
- Breaking: Move
keychange detection fromonDidUpdateWidgettoonBuildfor better support of late-created observers.
0.0.9 #
- Implement Observer composability - observers can create nested observers within any lifecycle method (
onInitState,onDidUpdateWidget,onBuild).
class ParentObserver extends LifecycleObserver<void> {
ChildObserver? child;
ParentObserver(super.state);
@override
void onInitState() {
super.onInitState();
// Create nested observers anywhere in lifecycle methods
child = ChildObserver(state);
}
}
0.0.8 #
- Add project logo and update README documentation.
- Add CI workflow with GitHub Actions and Codecov integration.
- Achieve 100% test coverage.
0.0.7 #
- Update documentation with
addLifecycleCallbackusage examples. - Add language switch links between English and Chinese README.
- Simplify code examples to use
late finalfor observer initialization.
0.0.6 #
- Replace
assertwithStateErrorfor missing mixin, correctaddLifecyccleCallbacktypo.
0.0.5 #
- Add
addLifecyccleCallback
void initState() {
super.initState();
addLifecycleCallback(
onInitState: () {
widget.log.onInitState++;
},
onDidUpdateWidget: () {
widget.log.onDidUpdateWidget++;
},
onDispose: () {
widget.log.onDispose++;
},
onBuild: (context) {
widget.log.onBuild++;
},
);
}
0.0.4 #
- Breaking Change: Renamed
LifecycleObserverMixintoLifecycleOwnerMixinto better reflect its role. - Breaking Change:
LifecycleObserverinitialization is now deferred.targetis available only afteronInitStateis called (which happens automatically). Accessing it prematurely throwsLateInitializationError. - Enhancement: Added automatic synchronization for "late" observers. Observers added after
initStateare now immediately initialized to catch up with the lifecycle. - Refactor: Introduced
LifecycleStateenum (created,initialized,disposed) to track component state. - Fix: Removed
StateWithObserversinterface in favor of checking againstLifecycleOwnerMixindirectly.
0.0.3 #
- Enhancement: Introduced
safeSetStateinLifecycleObserverto handle state updates safely across different scheduler phases. - Fix:
FutureObserverandStreamObservernow usesafeSetStateto prevent errors when updates are triggered during build, layout, or paint phases. - Docs: Reorganized README to clearly categorize built-in observers (Base, Widget, Anim) and added clarification on
keyusage.
0.0.2 #
- Breaking Change: Renamed
onUpdatetoonDidUpdateWidgetto better align with Flutter's lifecycle naming. - Breaking Change: Removed
onInit. Initialization logic should be moved to the constructor orbuildTarget. - Enhancement: Added safety assertion to ensure
statemixes inLifecycleObserverMixin. - Docs: Updated README with
keyusage explanation and new API examples.
0.0.1 #
- Initial release.
- Added
LifecycleObserverbase class andLifecycleOwnerMixin. - Included common observers:
AnimControllerObserver(supports fullAnimationControllerparams)ScrollControllerObserverTabControllerObserverTextEditingControllerObserver
- Implemented automatic lifecycle management (
onInit,onUpdate,onDispose). - Seamless integration via
super.build(context).