为什么当我导航到另一个屏幕时底部选项卡仍然可见?
Why Bottom Tab is still visible when I navigate to another screen?
这是应用程序中的登录页面,我的应用程序在登录后在底部选项卡下包含另外 2 个屏幕,但是当我尝试注销并导航回登录屏幕时,它确实导航但底部选项卡栏仍然存在不在登录页面的底部。
FlatButton.icon(
onPressed: () => {
_auth.signOutGoogle(),
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SignIn()))
},
icon: Icon(Icons.exit_to_app),
label: Text('Sign Out'))
这是我的注销按钮,下面是我的 main.dart 文件,我在其中定义了所有路由。
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()
},
)),
);
}
}
谢谢。
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'))
如果上述解决方案不起作用,请检查第二个解决方案
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'))
这是应用程序中的登录页面,我的应用程序在登录后在底部选项卡下包含另外 2 个屏幕,但是当我尝试注销并导航回登录屏幕时,它确实导航但底部选项卡栏仍然存在不在登录页面的底部。
FlatButton.icon(
onPressed: () => {
_auth.signOutGoogle(),
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SignIn()))
},
icon: Icon(Icons.exit_to_app),
label: Text('Sign Out'))
这是我的注销按钮,下面是我的 main.dart 文件,我在其中定义了所有路由。
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()
},
)),
);
}
}
谢谢。
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'))
如果上述解决方案不起作用,请检查第二个解决方案
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'))