I have my SessionStateStream set up in a Provider using River Pod like so:
final inactivityManagerProvider = ChangeNotifierProvider(
(ref) => InactivityManagerViewModel(),
);
class InactivityManagerViewModel with ChangeNotifier {
var sessionStateStream = StreamController<SessionState>();
SessionConfig? sessionConfig;
}
In MyApp's build method, I have initialized it like this:
final timeOutProvider = ref.watch(inactivityManagerProvider);
timeOutProvider.sessionConfig = SessionConfig(
invalidateSessionForAppLostFocus: const Duration(seconds: 40),
invalidateSessionForUserInactivity: const Duration(seconds: 40),
);
timeOutProvider.sessionConfig?.stream.listen((timeOutEvent) async {
// timeOutProvider.sessionStateStream.add(SessionState.stopListening);
if (timeOutEvent == SessionTimeoutState.userInactivityTimeout) {
await ref
.read(authenticationProvider)
.signOut(authToken: getIt<UserDependencies>().getAuthToken())
.then((value) {
NotificationManager.topBarNotifyError("Signed Out Due to Inactivity");
});
} else if (timeOutEvent == SessionTimeoutState.appFocusTimeout) {
await ref
.read(authenticationProvider)
.signOut(authToken: getIt<UserDependencies>().getAuthToken())
.then((value) {
NotificationManager.topBarNotifyError("Signed Out Due to Inactivity");
});
}
});
But whenever I want to use the sessionStateStream.add(SessionState.startListenint) from the provider, it pops the screen I'm going to and I'm not sure why.
I have my SessionStateStream set up in a Provider using River Pod like so:
In MyApp's build method, I have initialized it like this: