Remove unnecessary notifyListeners calls

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2025-05-14 11:11:45 +02:00
parent 7bf5a6d33d
commit 55ff65ba32
3 changed files with 5 additions and 13 deletions
@@ -20,8 +20,6 @@ class FavoriteColorService extends ArcaneService {
if (_notifier.value != newValue) { if (_notifier.value != newValue) {
_notifier.value = newValue; _notifier.value = newValue;
} }
notifyListeners();
} }
} }
@@ -67,7 +67,6 @@ class ArcaneAuthenticationService extends ArcaneService {
_notifier.value = AuthenticationStatus.unauthenticated; _notifier.value = AuthenticationStatus.unauthenticated;
_isSignedIn.value = isAuthenticated; _isSignedIn.value = isAuthenticated;
_previousModeWhenSettingDebug = null; _previousModeWhenSettingDebug = null;
notifyListeners();
} }
/// Registers an `ArcaneAuthInterface` within the `ArcaneAuthenticationService`. /// Registers an `ArcaneAuthInterface` within the `ArcaneAuthenticationService`.
@@ -157,7 +156,6 @@ class ArcaneAuthenticationService extends ArcaneService {
_notifier.value = newStatus; _notifier.value = newStatus;
_isSignedIn.value = isAuthenticated; _isSignedIn.value = isAuthenticated;
} }
notifyListeners();
} }
/// Logs the current user out. Upon successful logout, `status` will be set to /// Logs the current user out. Upon successful logout, `status` will be set to
@@ -82,7 +82,6 @@ class ArcaneFeatureFlags extends ArcaneService {
); );
} }
notifyListeners();
return I; return I;
} }
@@ -111,7 +110,6 @@ class ArcaneFeatureFlags extends ArcaneService {
); );
} }
notifyListeners();
return I; return I;
} }
@@ -121,12 +119,9 @@ class ArcaneFeatureFlags extends ArcaneService {
/// It is called automatically when enabling or disabling features if they haven't /// It is called automatically when enabling or disabling features if they haven't
/// already been initialized. /// already been initialized.
void _init() { void _init() {
_notifier.value = []; if (I._initialized) return;
reset();
notifier.addListener(_listener);
I._initialized = true; I._initialized = true;
notifyListeners();
} }
/// Resets the feature flags to their initial state. /// Resets the feature flags to their initial state.
@@ -134,10 +129,11 @@ class ArcaneFeatureFlags extends ArcaneService {
/// This method clears all enabled features, resets notification values, /// This method clears all enabled features, resets notification values,
/// marks the flags as uninitialized, and notifies listeners of the changes. /// marks the flags as uninitialized, and notifies listeners of the changes.
void reset() { void reset() {
notifier
..removeListener(_listener)
..addListener(_listener);
_notifier.value = []; _notifier.value = [];
I._initialized = false; I._initialized = false;
notifyListeners();
} }
void _listener() { void _listener() {