我正在为导航栏制作另一个文件。问题是当我尝试添加到我的主页时,因为我使用了Scaffold,它只是隐藏了我的主页中包含的所有内容。我如何修改NavigationBar的文件以使其正常工作(仅是一个小部件)并且不影响UI的其余部分。这是代码
import 'package:flutter/material.dart';
import 'google_nav_bar.dart';
class AppBarW extends StatefulWidget {
@override
_AppBarState createState() => _AppBarState();
}
class _AppBarState extends State<AppBarW> {
int _selectedIndex = 0;
static const TextStyle optionStyle =
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
static const List<Widget> _widgetOptions = <Widget>[
Text(
'Index 0: Home',
style: optionStyle,
),
Text(
'Index 1: Likes',
style: optionStyle,
),
Text(
'Index 2: Search',
style: optionStyle,
),
Text(
'Index 3: Profile',
style: optionStyle,
),
];
@override
Widget build(BuildContext context) {
return Scaffold(
body:
Container(
padding: EdgeInsets.only(top: MediaQuery.of(context).size.height * 0.7),
child: new BottomAppBar(
child: Container(
decoration: BoxDecoration(color: Colors.white, boxShadow: [
BoxShadow(blurRadius: 20, color: Colors.black.withOpacity(.1))
]),
child: SafeArea(
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 15.0, vertical: 8),
child: GNav(
gap: 8,
activeColor: Colors.white,
iconSize: 24,
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 5),
duration: Duration(milliseconds: 800),
tabBackgroundColor: Colors.grey[800],
tabs: [
GButton(
icon: Icons.home,
text: 'Home',
),
GButton(
icon: Icons.favorite,
text: 'Likes',
),
GButton(
icon: Icons.search,
text: 'Search',
),
GButton(
icon: Icons.person_pin_circle,
text: 'Profile',
),
],
selectedIndex: _selectedIndex,
onTabChange: (index) {
setState(() {
_selectedIndex = index;
});
}),
),
),
),
) ));
}
}