From a2bcf15c855ea36e79048ccabdf74800c16bdb3f Mon Sep 17 00:00:00 2001 From: Surya Jillellamudi Date: Thu, 12 Sep 2024 12:51:41 +0530 Subject: [PATCH] State Unmounted issue on Change in Event Queue --- example/pubspec.lock | 2 +- lib/livedata.dart | 7 ++++++- lib/src/eventqueue.dart | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 79f82b5..8a17ead 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -94,7 +94,7 @@ packages: path: ".." relative: true source: path - version: "1.0.4" + version: "1.0.6" leak_tracker: dependency: transitive description: diff --git a/lib/livedata.dart b/lib/livedata.dart index 472ee72..77da00f 100644 --- a/lib/livedata.dart +++ b/lib/livedata.dart @@ -1,2 +1,7 @@ export 'src/livedata.dart' - show LiveData, MutableLiveData, LiveDataObserver, LiveDataBuilder, LiveDataListener; + show + LiveData, + MutableLiveData, + LiveDataObserver, + LiveDataBuilder, + LiveDataListener; diff --git a/lib/src/eventqueue.dart b/lib/src/eventqueue.dart index 707effc..b8340ee 100644 --- a/lib/src/eventqueue.dart +++ b/lib/src/eventqueue.dart @@ -83,6 +83,7 @@ class _EventListenerState extends State> { if (!_handledInitialValue) { _handledInitialValue = true; WidgetsBinding.instance.addPostFrameCallback((_) { + if (!mounted) return; _onChange(context, widget.eventQueue._nextEvent.value); }); }