为什么切换到子页面后隐藏我的Boots导航栏?我希望在每个子页面或选定页面上都可以看到它,但是现在,单击子页面后,他开始了障碍,当我复出时,他仍然隐藏着
这是我的代码:
class _NavBarState extends State<NavBar> {
final List<TitledNavigationBarItem> items = [
TitledNavigationBarItem(title: 'Maps', icon: Icons.location_on),
// TitledNavigationBarItem(title: 'SEARCH', icon: Icons.search),
TitledNavigationBarItem(title: 'Home', icon: Icons.home),
TitledNavigationBarItem(title: 'Profile', icon: Icons.person),
];
int _selectedPage = 1;
final List _pageOptions = [
MapScreen(),
HomeScreen(),
ProfileScreen(),
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: _pageOptions[_selectedPage],
bottomNavigationBar: TitledBottomNavigationBar(
onTap: (int index) {
setState(() {
_selectedPage = index;
});
},
reverse: true,
curve: Curves.easeInBack,
items: items,
currentIndex: _selectedPage,
activeColor: Colors.red,
inactiveColor: Colors.blueGrey,
),
);
}
}
问题是单击此ListTile
之一后,
单击后正确地将我转移到相应的子页面,但是当我返回到上一页时,我的底部导航栏不在此处,我也不知道为什么,
这是我从底部导航栏到子页面列表的3页之一:
class _ProfileScreenState extends State<ProfileScreen>{
SharedPreferences sharedPreferences;
UserApiService userApiService;
@override
void initState() {
super.initState();
checkStorageStatus();
userApiService = UserApiService();
}
checkStorageStatus() async {
sharedPreferences = await SharedPreferences.getInstance();
}
@override
Widget build(BuildContext context) {
double height = MediaQuery.of(context).size.height;
double width = MediaQuery.of(context).size.width;
return FutureBuilder<SharedPreferences>(
future: SharedPreferences.getInstance(),
builder: (context, snapshot){
if(!snapshot.hasData){
return Scaffold(
body: CircularProgressIndicator(),
);
}
return Scaffold(
body: SingleChildScrollView(
child: Container(
padding: EdgeInsets.only(right: 30.0, top: 40.0),
child: Padding(
padding: EdgeInsets.only(top: 20, left:20, bottom: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
Padding(
padding: EdgeInsets.all(15.0),
child: CircleAvatar(
radius: 40,
//TODO: użyć sharedpreferences na koncu by wstawialo faktyczne zdjecia
backgroundImage: NetworkImage('https://upload.wikimedia.org/wikipedia/commons/8/8d/George_Clooney_2016.jpg'),
backgroundColor: Colors.transparent,
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
sharedPreferences.getString('firstName') + ' ' + sharedPreferences.getString('lastName'),
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold
),
),
Text(
'#' + sharedPreferences.getString('accountName')
)
],
)
],
),
SizedBox(height: 30.0),
Divider(),
Padding(
padding: EdgeInsets.only(left:20, top: 20),
child: Row(
children: <Widget>[
Text(
'KONTO',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Color.fromRGBO(136, 136, 136, 10)
),
)
]
)),
SizedBox(height: 10.0),
Padding(
padding: EdgeInsets.only(bottom: 5.0),
child: ListTile(
leading: Icon(Icons.person, color: Colors.black, size: 30,),
title: Text(
'Profil',
style: TextStyle(fontSize: 16.0,letterSpacing: 1.0, color: Colors.black,),
),
trailing: Icon(Icons.arrow_forward_ios),
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => UserScreen()));
},
),
),
],
)),
)),
);});
}
和我的main.dart
import 'package:flutter/material.dart';
import 'package:prod_name/ui/login/login_screen.dart';
import 'package:prod_name/ui/start/start_screen.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: StartScreen(), // I WANT TO START APP WITH THIS SCREEN
);
}
}
如果您有任何问题,请回答,谢谢您