This is the signin page in the app and my app contains 2 more screens under bottom tab after signing in but when I try to logout and Navigate back to signin screen ,it does navigate but the bottom tab bar still remains in the bottom which is not in the SignIn page.
FlatButton.icon(
onPressed: () => {
_auth.signOutGoogle(),
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SignIn()))
},
icon: Icon(Icons.exit_to_app),
label: Text('Sign Out'))
This is my logout button and below is my main.dart file where I defined all the routes.
void main() {
SystemChrome.setEnabledSystemUIOverlays([]);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
StreamProvider.value(value: AuthService().user),
],
child: Consumer<User>(
builder: (ctx, auth, _) => MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Wrapper(),
routes: {
'/homescreen': (ctx) => HomeScreen(),
'/signin': (ctx) => SignIn(),
'/dashboard': (ctx) => DashBoard(),
'/status': (ctx) => Status()
},
)),
);
}
}
Thank You.
FlatButton.icon(
onPressed: () => {
_auth.signOutGoogle(),
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (context) => SignIn()),
(Route<dynamic> route) => false,);
},
icon: Icon(Icons.exit_to_app),
label: Text('Sign Out'))
if above solution doesn't work check this 2nd solution
FlatButton.icon(
onPressed: () => {
_auth.signOutGoogle(),
Navigator.of(context, rootNavigator: true).pushReplacement(
MaterialPageRoute(builder: (context) => SignIn()));
},
icon: Icon(Icons.exit_to_app),
label: Text('Sign Out'))