I took your login example and tried to play with it a little and I added a drawer with some entriues and a logout button at the bottom of it.
This is the drawer code:
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_login/authentication/authentication.dart';
class AppDrawer extends StatelessWidget {
@override
Widget build(BuildContext context) {
final AuthenticationBloc authenticationBloc =
BlocProvider.of<AuthenticationBloc>(context);
return Drawer(
child: Column(
children: <Widget>[
MediaQuery.removePadding(
context: context,
removeTop: true,
child: Expanded(
child: ListView(
padding: const EdgeInsets.only(top: 8.0),
children: <Widget>[
ListTile(
leading: Icon(Icons.group),
title: Text("Page 1"),
onTap: () {
Navigator.pushReplacementNamed(context, '/page1');
},
),
ListTile(
leading: Icon(Icons.group),
title: Text("Home"),
onTap: () {
Navigator.pushReplacementNamed(context, '/');
},
),
ListTile(
leading: Icon(Icons.exit_to_app),
title: Text('Logout'),
onTap: () {
Navigator.pop(context);
authenticationBloc.dispatch(LoggedOut());
},
)
],
),
),
),
],
),
);
}
}
then I created a new page page1.dart:
import 'package:flutter/material.dart';
import 'package:flutter_login/app_drawer.dart';
class Page1 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Page1'),
),
drawer: AppDrawer(),
body: Text('Hi there'),
);
}
}
and finally I updated the home_page.dart to add the drawer:
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_login/authentication/authentication.dart';
import 'package:flutter_login/app_drawer.dart';
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final AuthenticationBloc authenticationBloc =
BlocProvider.of<AuthenticationBloc>(context);
return Scaffold(
appBar: AppBar(
title: Text('Home'),
),
drawer: AppDrawer(),
body: Container(
child: Center(
child: RaisedButton(
child: Text('logout'),
onPressed: () {
authenticationBloc.dispatch(LoggedOut());
},
)),
),
);
}
}
main.dart:
import 'package:flutter/material.dart';
import 'package:bloc/bloc.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:user_repository/user_repository.dart';
import 'package:flutter_login/authentication/authentication.dart';
import 'package:flutter_login/splash/splash.dart';
import 'package:flutter_login/login/login.dart';
import 'package:flutter_login/home/home.dart';
import 'package:flutter_login/common/common.dart';
import 'package:flutter_login/page1.dart';
class SimpleBlocDelegate extends BlocDelegate {
@override
void onTransition(Transition transition) {
print(transition);
}
@override
void onError(Object error, StackTrace stacktrace) {
print(error);
}
}
void main() {
BlocSupervisor().delegate = SimpleBlocDelegate();
runApp(App(userRepository: UserRepository()));
}
class App extends StatefulWidget {
final UserRepository userRepository;
App({Key key, @required this.userRepository}) : super(key: key);
@override
State<App> createState() => _AppState();
}
class _AppState extends State<App> {
AuthenticationBloc _authenticationBloc;
UserRepository get _userRepository => widget.userRepository;
@override
void initState() {
_authenticationBloc = AuthenticationBloc(userRepository: _userRepository);
_authenticationBloc.dispatch(AppStarted());
super.initState();
}
@override
void dispose() {
_authenticationBloc.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return BlocProvider<AuthenticationBloc>(
bloc: _authenticationBloc,
child: MaterialApp(
routes: {
'/page1': (_) => Page1(),
},
home: BlocBuilder<AuthenticationEvent, AuthenticationState>(
bloc: _authenticationBloc,
builder: (BuildContext context, AuthenticationState state) {
if (state is AuthenticationUninitialized) {
return SplashPage();
}
if (state is AuthenticationAuthenticated) {
return HomePage();
}
if (state is AuthenticationUnauthenticated) {
return LoginPage(userRepository: _userRepository);
}
if (state is AuthenticationLoading) {
return LoadingIndicator();
}
},
),
),
);
}
}
When i try to logout, the bloc correctly change the state to AuthenticationUnauthenticated, but the BlocBuilder builder method is not triggered and the login page is not displayed.
flutter: Transition { currentState: LoginInitial, event: LoginButtonPressed { username: , password: }, nextState: LoginLoading }
flutter: Transition { currentState: LoginLoading, event: LoginButtonPressed { username: , password: }, nextState: LoginInitial }
flutter: Transition { currentState: AuthenticationUnauthenticated, event: LoggedIn { token: token }, nextState: AuthenticationLoading }
flutter: Transition { currentState: AuthenticationLoading, event: LoggedIn { token: token }, nextState: AuthenticationAuthenticated }
flutter: Transition { currentState: AuthenticationAuthenticated, event: LoggedOut, nextState: AuthenticationLoading }
flutter: Transition { currentState: AuthenticationLoading, event: LoggedOut, nextState: AuthenticationUnauthenticated }
Can you help please?
Note that you have to visite Page 1 to reproduce this issue.

@boukmi thanks for opening an issue!
I think the issue youβre facing is you are disposing the widget along with BlocBuilder when you use pushReplacementNamed. I would recommend just using push and pop otherwise you destroy the underlying views in the navigation stack.
Let me know if that helps π
@felangel thank you for your quick reply
I updated the drawer code:
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_login/authentication/authentication.dart';
import 'package:flutter_login/page1.dart';
import 'package:flutter_login/home/home.dart';
class AppDrawer extends StatelessWidget {
@override
Widget build(BuildContext context) {
final AuthenticationBloc authenticationBloc =
BlocProvider.of<AuthenticationBloc>(context);
return BlocBuilder<AuthenticationEvent, AuthenticationState>(
bloc: authenticationBloc,
builder: (BuildContext context, AuthenticationState state) {
return Drawer(
child: Column(
children: <Widget>[
MediaQuery.removePadding(
context: context,
removeTop: true,
child: Expanded(
child: ListView(
padding: const EdgeInsets.only(top: 8.0),
children: <Widget>[
ListTile(
leading: Icon(Icons.group),
title: Text("Page 1"),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (_) => Page1()),
);
},
),
ListTile(
leading: Icon(Icons.group),
title: Text("Home"),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (_) => HomePage()),
);
},
),
ListTile(
leading: Icon(Icons.exit_to_app),
title: Text('Logout'),
onTap: () {
authenticationBloc.dispatch(LoggedOut());
},
)
],
),
),
),
],
),
);
},
);
}
}
Still does not work and now I'm getting this error when I click on logout button:
```
flutter: βββ‘ EXCEPTION CAUGHT BY WIDGETS LIBRARY ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
flutter: The following assertion was thrown while finalizing the widget tree:
flutter: setState() or markNeedsBuild() called when widget tree was locked.
flutter: This _ModalScope
flutter: locked.
flutter: The widget on which setState() or markNeedsBuild() was called was:
flutter: _ModalScope
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 Element.markNeedsBuild.
package:flutter/β¦/widgets/framework.dart:3514
flutter: #1 Element.markNeedsBuild
package:flutter/β¦/widgets/framework.dart:3523
flutter: #2 State.setState
package:flutter/β¦/widgets/framework.dart:1138
flutter: #3 _ModalScopeState._routeSetState
package:flutter/β¦/widgets/routes.dart:622
flutter: #4 ModalRoute.setState
package:flutter/β¦/widgets/routes.dart:721
flutter: #5 ModalRoute.changedInternalState
package:flutter/β¦/widgets/routes.dart:1192
flutter: #6 _ModalRoute&TransitionRoute&LocalHistoryRoute.removeLocalHistoryEntry
package:flutter/β¦/widgets/routes.dart:506
flutter: #7 LocalHistoryEntry.remove
package:flutter/β¦/widgets/routes.dart:337
flutter: #8 DrawerControllerState.dispose
package:flutter/β¦/material/drawer.dart:242
flutter: #9 StatefulElement.unmount
package:flutter/β¦/widgets/framework.dart:3916
flutter: #10 _InactiveElements._unmount
package:flutter/β¦/widgets/framework.dart:1696
flutter: #11 _InactiveElements._unmount.
package:flutter/β¦/widgets/framework.dart:1694
flutter: #12 ComponentElement.visitChildren
package:flutter/β¦/widgets/framework.dart:3770
flutter: #13 _InactiveElements._unmount
package:flutter/β¦/widgets/framework.dart:1692
flutter: #14 _InactiveElements._unmount.
package:flutter/β¦/widgets/framework.dart:1694
flutter: #15 ComponentElement.visitChildren
package:flutter/β¦/widgets/framework.dart:3770
flutter: #16 _InactiveElements._unmount
package:flutter/β¦/widgets/framework.dart:1692
flutter: #17 _InactiveElements._unmount.
package:flutter/β¦/widgets/framework.dart:1694
flutter: #18 MultiChildRenderObjectElement.visitChildren
package:flutter/β¦/widgets/framework.dart:4965
flutter: #19 _InactiveElements._unmount
package:flutter/β¦/widgets/framework.dart:1692
flutter: #20 _InactiveElements._unmount.
package:flutter/β¦/widgets/framework.dart:1694
flutter: #21 ComponentElement.visitChildren
package:flutter/β¦/widgets/framework.dart:3770
flutter: #22 _InactiveElements._unmount
package:flutter/β¦/widgets/framework.dart:1692
flutter: #23 _InactiveElements._unmount.
package:flutter/β¦/widgets/framework.dart:1694
flutter: #24 ComponentElement.visitChildren
package:flutter/β¦/widgets/framework.dart:3770
flutter: #25 _InactiveElements._unmount
flutter: #29 _InactiveElements._unmount.
package:flutter/β¦/widgets/framework.dart:1694
flutter: #30 SingleChildRenderObjectElement.visitChildren
package:flutter/β¦/widgets/framework.dart:4864
flutter: #31 _InactiveElements._unmount
package:flutter/β¦/widgets/framework.dart:1692
flutter: #32 _InactiveElements._unmount.
package:flutter/β¦/widgets/framework.dart:1694
flutter: #33 ComponentElement.visitChildren
package:flutter/β¦/widgets/framework.dart:3770
flutter: #34 _InactiveElements._unmount
package:flutter/β¦/widgets/framework.dart:1692
flutter: #35 _InactiveElements._unmount.
package:flutter/β¦/widgets/framework.dart:1694
flutter: #36 SingleChildRenderObjectElement.visitChildren
package:flutter/β¦/widgets/framework.dart:4864
flutter: #37 _InactiveElements._unmount
package:flutter/β¦/widgets/framework.dart:1692
flutter: #38 _InactiveElements._unmount.
package:flutter/β¦/widgets/framework.dart:1694
flutter: #39 ComponentElement.visitChildren
package:flutter/β¦/widgets/framework.dart:3770
flutter: #40 _InactiveElements._unmount
package:flutter/β¦/widgets/framework.dart:1692
flutter: #41 _InactiveElements._unmount.
package:flutter/β¦/widgets/framework.dart:1694
flutter: #42 ComponentElement.visitChildren
package:flutter/β¦/widgets/framework.dart:3770
flutter: #43 _InactiveElements._unmount
package:flutter/β¦/widgets/framework.dart:1692
flutter: #44 _InactiveElements._unmount.
package:flutter/β¦/widgets/framework.dart:1694
flutter: #45 ComponentElement.visitChildren
package:flutter/β¦/widgets/framework.dart:3770
flutter: #46 _InactiveElements._unmount
package:flutter/β¦/widgets/framework.dart:1692
flutter: #47 _InactiveElements._unmount.
package:flutter/β¦/widgets/framework.dart:1694
flutter: #48 ComponentElement.visitChildren
package:flutter/β¦/widgets/framework.dart:3770
flutter: #49 _InactiveElements._unmount
package:flutter/β¦/widgets/framework.dart:1692
flutter: #50 _InactiveElements._unmount.
package:flutter/β¦/widgets/framework.dart:1694
flutter: #51 ComponentElement.visitChildren
package:flutter/β¦/widgets/framework.dart:3770
flutter: #52 _InactiveElements._unmount
package:flutter/β¦/widgets/framework.dart:1692
flutter: #53 _InactiveElements._unmount.
package:flutter/β¦/widgets/framework.dart:1694
flutter: #54 ComponentElement.visitChildren
package:flutter/β¦/widgets/framework.dart:3770
flutter: #55 _InactiveElements._unmount
package:flutter/β¦/widgets/framework.dart:1692
flutter: #56 ListIterable.forEach (dart:_internal/iterable.dart:39:13)
flutter: #57 _InactiveElements._unmountAll
package:flutter/β¦/widgets/framework.dart:1705
flutter: #58 BuildOwner.finalizeTree.
package:flutter/β¦/widgets/framework.dart:2359
flutter: #59 BuildOwner.lockState
package:flutter/β¦/widgets/framework.dart:2191
flutter: #60 BuildOwner.finalizeTree
package:flutter/β¦/widgets/framework.dart:2358
flutter: #61 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame
package:flutter/β¦/widgets/binding.dart:702
flutter: #62 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback
package:flutter/β¦/rendering/binding.dart:268
flutter: #63 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback
package:flutter/β¦/scheduler/binding.dart:988
flutter: #64 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame
flutter: #65 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame
package:flutter/β¦/scheduler/binding.dart:840
flutter: #69 _invoke (dart:ui/hooks.dart:209:10)
flutter: #70 _drawFrame (dart:ui/hooks.dart:168:3)
flutter: (elided 3 frames from package dart:async)
flutter: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
flutter: Transition { currentState: AuthenticationLoading, event: LoggedOut, nextState: AuthenticationUnauthenticated }
Thank you for your help and sorry to disturb you
No problem! Can you please share the full source code with me on github?
Of course and thank you so much!
Here is the link to the github repository
https://github.com/boukmi/flutter_login
@boukmi I just opened a PR with some enhancements to make everything work the way I expect you wanted. Let me know if that helps π
@felangel thank you so much for your help.
I'll check it out in the morning and let you, it's getting late in Europe now π
@boukmi sounds good! Closing this for now but feel free to comment with any further questions/concerns and I'll gladly reopen it π
It worked π thanks a lot
The only downside I see is that it removes animation when navigating between pages.
@boukmi yeah check out
https://github.com/felangel/bloc/issues/18 for one way to retain animations.
Awesome Iβll try it!
Hi @felangel and I'm sorry to disturb you again but I'm trying to make this example work perfectly.
I updated the home_page.dart to retain animations like so:
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_login/home/home.dart';
import 'package:flutter_login/authentication/authentication.dart';
import 'package:flutter_login/app_drawer.dart';
import 'package:flutter_login/page1.dart';
class HomePage extends StatefulWidget {
@override
State<StatefulWidget> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final HomeBloc _homeBloc = HomeBloc();
final PageController _pageController = PageController();
_HomePageState() {
_homeBloc.state.listen(
(state) {
if (state is HomePageActive) {
_pageController.animateToPage(
0, // HomePage
curve: Curves.ease,
duration: Duration(milliseconds: 300),
);
return;
}
if (state is Page1Active) {
_pageController.animateToPage(
1, // LoginPage
curve: Curves.ease,
duration: Duration(milliseconds: 300),
);
}
},
);
}
@override
Widget build(BuildContext context) {
return BlocProvider(
bloc: _homeBloc,
child: PageView(
physics: NeverScrollableScrollPhysics(),
children: [
_HomePage(),
Page1(),
],
controller: _pageController,
),
);
}
@override
void dispose() {
_homeBloc.dispose();
super.dispose();
}
}
class _HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final AuthenticationBloc authenticationBloc =
BlocProvider.of<AuthenticationBloc>(context);
return Scaffold(
appBar: AppBar(
title: Text('Home'),
),
drawer: AppDrawer(),
body: Container(
child: Center(
child: RaisedButton(
child: Text('logout'),
onPressed: () {
authenticationBloc.dispatch(LoggedOut());
},
),
),
),
);
}
}
But I have a strange behaviour when I click on Home button.

Any idea why?
Hi, I am having login n logout issue with bloc, While I am logging in it is not changing the screen on main.dart, I debug it, main.dart bloc builder not updating the state there. While i do hard restart then it changes the screen. here is my code https://github.com/pardipbhatti8791/login-issue . Please help me out with this.
same is happening for the logout. I tried a lot but no solution found yet.
@pardipbhatti8791 I took a look and it's because you're both using BlocProvider and manually disposing the bloc yourself. The rule is whoever creates the bloc should dispose it so whenever you're using BlocProvider(builder: (context) => MyBloc(), child: ...) BlocProvider will automatically handle disposing the bloc for you.
With that said, your TribeApp widget no longer needs to be a StatefulWidget.
class TribeApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final authenticationBloc = BlocProvider.of<IfAuthenticatedBloc>(context);
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: BlocBuilder<IfAuthenticatedBloc, IfAuthenticatedState>(
builder: (BuildContext context, IfAuthenticatedState state) {
if (state is Unauthenticated) {
return SlidesScreen();
}
if (state is Authenticated) {
return Scaffold(
body: Container(
child: Center(
child: RaisedButton(
onPressed: () => authenticationBloc.dispatch(LoggedOut()),
child: Text('Log Out'),
),
),
),
);
}
return SplashScreen();
},
),
routes: {
LoginScreen.route: (context) => LoginScreen(),
SlidesScreen.route: (context) => SlidesScreen(),
},
);
}
}
Hope that helps π
I tried the stateless widget as well without disposing. But still getting
the same. My client is keep asking me updates, And I am stuck here in state
management. Seems like I need to go back to React Native. I am Javascript
developer. I thought should try Flutter I liked it but state management is
huge issue here.
On Mon, Aug 12, 2019 at 3:42 AM Felix Angelov notifications@github.com
wrote:
@pardipbhatti8791 https://github.com/pardipbhatti8791 I took a look and
it's because you're both using BlocProvider and manually disposing the
bloc yourself. The rule is whoever creates the bloc should dispose it so
whenever you're using BlocProvider(builder: (context) => MyBloc(), child:
...) BlocProvider will automatically handle disposing the bloc for you.With that said, your TribeApp widget no longer needs to be a
StatefulWidget.class TribeApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final authenticationBloc = BlocProvider.of<IfAuthenticatedBloc>(context); return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: BlocBuilder<IfAuthenticatedBloc, IfAuthenticatedState>( builder: (BuildContext context, IfAuthenticatedState state) { if (state is Unauthenticated) { return SlidesScreen(); } if (state is Authenticated) { return Scaffold( body: Container( child: Center( child: RaisedButton( onPressed: () => authenticationBloc.dispatch(LoggedOut()), child: Text('Log Out'), ), ), ), ); } return SplashScreen(); }, ), routes: { LoginScreen.route: (context) => LoginScreen(), SlidesScreen.route: (context) => SlidesScreen(), }, );}
}
Hope that helps π
β
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/felangel/bloc/issues/122?email_source=notifications&email_token=ADL5SY2R6FPEDMKKNSDHCFLQECFDRA5CNFSM4G3NJWAKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4BJ4YI#issuecomment-520265313,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADL5SY7RHG3ZTEGSE3GMW63QECFDRANCNFSM4G3NJWAA
.
Still not taking me home after login, progress Indicator start then nothing
happens. I need to hard restart again then it took me to home screen.
On Mon, Aug 12, 2019 at 3:46 AM Pardip Bhatti pardipbhatti8791@gmail.com
wrote:
I tried the stateless widget as well without disposing. But still getting
the same. My client is keep asking me updates, And I am stuck here in state
management. Seems like I need to go back to React Native. I am Javascript
developer. I thought should try Flutter I liked it but state management is
huge issue here.On Mon, Aug 12, 2019 at 3:42 AM Felix Angelov notifications@github.com
wrote:@pardipbhatti8791 https://github.com/pardipbhatti8791 I took a look
and it's because you're both using BlocProvider and manually disposing
the bloc yourself. The rule is whoever creates the bloc should dispose it
so whenever you're using BlocProvider(builder: (context) => MyBloc(),
child: ...) BlocProvider will automatically handle disposing the bloc
for you.With that said, your TribeApp widget no longer needs to be a
StatefulWidget.class TribeApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final authenticationBloc = BlocProvider.of<IfAuthenticatedBloc>(context); return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: BlocBuilder<IfAuthenticatedBloc, IfAuthenticatedState>( builder: (BuildContext context, IfAuthenticatedState state) { if (state is Unauthenticated) { return SlidesScreen(); } if (state is Authenticated) { return Scaffold( body: Container( child: Center( child: RaisedButton( onPressed: () => authenticationBloc.dispatch(LoggedOut()), child: Text('Log Out'), ), ), ), ); } return SplashScreen(); }, ), routes: { LoginScreen.route: (context) => LoginScreen(), SlidesScreen.route: (context) => SlidesScreen(), }, );}
}
Hope that helps π
β
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/felangel/bloc/issues/122?email_source=notifications&email_token=ADL5SY2R6FPEDMKKNSDHCFLQECFDRA5CNFSM4G3NJWAKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4BJ4YI#issuecomment-520265313,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADL5SY7RHG3ZTEGSE3GMW63QECFDRANCNFSM4G3NJWAA
.
@pardipbhatti8791 can you message me on gitter? I'm more than happy to help you debug the issue further but I don't have valid credentials to actually login.
Just did
On Mon, Aug 12, 2019 at 4:14 AM Felix Angelov notifications@github.com
wrote:
@pardipbhatti8791 https://github.com/pardipbhatti8791 can you message
me on gitter https://gitter.im/bloc_package/Lobbyβ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/felangel/bloc/issues/122?email_source=notifications&email_token=ADL5SY7WYEXJCOKGOB3WCR3QECI6BA5CNFSM4G3NJWAKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4BKMOY#issuecomment-520267323,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADL5SY47YDF6CADZ3JZXG3TQECI6BANCNFSM4G3NJWAA
.
Hi @felangel ,
In my app navigating multiple screens and after came back to HomeScreen in HomeScreen menu click on logout it should go loginScreen but not happening using bloc.
example-1:
i am using bloc in my application and after login->homePage->tabBars->newScreen->anotherNewScreen->click on back to Home screen and if i click on logout it is not navigating to login screen.
example -2:
i am using this example
https://github.com/boukmi/flutter_login
->in the above example also not working multiple navigation.
->in the above example i just added the new screen and navigating from page 1 to newScreen and in newScreen click on logout. then it should move to login screen but not working.
@janardhanmupparaju if you push new routes onto the stack you need to pop them before you add the LoggedOut event.
Navigator.of(context).popUntil(ModalRoute.withName('/'));
// then add/dispatch LoggedOut()
@janardhanmupparaju if you push new routes onto the stack you need to pop them before you add the
LoggedOutevent.Navigator.of(context).popUntil(ModalRoute.withName('/')); // then add/dispatch LoggedOut()
Thank you @felangel , it was working. i just added that line before dispatch LoggedOut().
Most helpful comment
Thank you @felangel , it was working. i just added that line before dispatch LoggedOut().