Closed peter910921 closed 1 year ago
Hi,
you are referring to add in this line right?
_signInBloc.state.sessionStateStream.add(SessionState.stopListening);
Hi,
you are referring to add in this line right?
_signInBloc.state.sessionStateStream.add(SessionState.stopListening);
Yes this line. Other than this line, i also have a page which login page whenever they press login i will start listen _signInBloc.state.sessionStateStream.add(SessionState.startListening);
Same thing happen when they press the login button which it will start listening
Can you post the code related to AuthBloc? (Onlythe state definition of the bloc)
Can you post the code related to AuthBloc? (Onlythe state definition of the bloc)
// ignore_for_file: public_member_api_docs, sort_constructors_first
part of 'auth_bloc.dart';
class AuthState extends Equatable {
final LoadingStatus status;
final CustomErr err;
final StreamController<SessionState> sessionStateStream;
final bool sessionExpired;
AuthState({
required this.status,
required this.err,
required this.user,
required this.sessionStateStream,
required this.sessionExpired,
});
factory AuthState.initial() {
return AuthState(
sessionStateStream: StreamController<SessionState>(),
sessionExpired: false,
status: LoadingStatus.initial,
err: CustomErr(errMsg: '')
);
}
@override
List<Object> get props => [status];
@override
bool get stringify => true;
AuthState copyWith({
LoadingStatus? status,
CustomErr? err,
StreamController<SessionState>? sessionStateStream,
SessionConfig? sessionConfig,
bool? sessionExpired,
}) {
return AuthState(
status: status ?? this.status,
err: err ?? this.err,
sessionStateStream: sessionStateStream ?? this.sessionStateStream,
sessionExpired: sessionExpired ?? this.sessionExpired,
);
}
}
Little unusual that it goes away after Applocalizations is commented.
While AppLocalizations is not commented, did you notice rebuilds for MaterialApp at any other point (other than sessionStream.add)
Little unusual that it goes away after Applocalizations is commented.
While AppLocalizations is not commented, did you notice rebuilds for MaterialApp at any other point (other than sessionStream.add)
Everything just working fine actually only until the point i click on the login button which trigger
context.read<AuthBloc>().state.sessionStateStream.add(SessionState.startListening);
then it rebuild but it doesn't happen after i comment out AppLocalizations(). Its really kind a weird, i try to move SessionTimeoutManager to the Login Page, it works without comment AppLocalizations(), but then it is not at the top of the widget tree, so whenever i pushNamed, it cant detect user activity anymore, so i have no choice to put at MaterialApp().
I tried it without using bloc and the result is still the same.
Can you post a minimal example to reproduce it if possible
Can you post a minimal example to reproduce it if possible
i think i need some time on this. Will come back to you once i finished the minimal example. Thanks.
@peter910921 let me know if you need any help to create the minimal example
@SankethBK Hi sorry for the late reply, been busy on my work.
Actually i think i end up changing my app localizations delegates by following the flutter official guide. After that all working fine now. https://docs.flutter.dev/development/accessibility-and-localization/internationalization
localizationsDelegates: [
AppLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate
],
Cool
Hi,
I have this issue where the whole MaterialApp() seems like rebuild whenever i try to do sessionStateStream.add(). After troubleshooting a while i found out that after i remove the AppLocalizations delegate from my MaterialApp(), it is working as usual without keep rebuilding everytime i do sessionStateStream.add(). Do you have any idea what is going on?
Thanks in advance.
My AppLocalizations class