Flutter 我的导航栏后面的黑色是从哪里来的?
绕过导航栏的各个角落后,我注意到那里还有一些东西。当我将脚手架背景颜色设置为透明时,导航栏后面的是黑色。。如果我把它换成蓝色,它就是蓝色的。。那是脚手架吗?如何让它显示我的主页?我是新来的Flutter 我的导航栏后面的黑色是从哪里来的?,flutter,dart,Flutter,Dart,绕过导航栏的各个角落后,我注意到那里还有一些东西。当我将脚手架背景颜色设置为透明时,导航栏后面的是黑色。。如果我把它换成蓝色,它就是蓝色的。。那是脚手架吗?如何让它显示我的主页?我是新来的 class Navigation extends StatefulWidget { @override _NavigationState createState() => _NavigationState(); } class _NavigationState extends State<
class Navigation extends StatefulWidget {
@override
_NavigationState createState() => _NavigationState();
}
class _NavigationState extends State<Navigation> {
int _selectedIndex = 0;
List<Widget> _widgetOptions = <Widget>[
Home(),
Options(),
Menu(),
Search (),
Text ('Profile')
];
void _onItemTap(int index) {
setState(() {
_selectedIndex = index;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
body: Stack (
children: [_widgetOptions.elementAt(_selectedIndex)],
),
bottomNavigationBar: Container(
margin: EdgeInsets.zero,
decoration: BoxDecoration(
color: Color (0xFF213359),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0),
topRight: Radius.circular(30.0),),),
child: Theme(
data: ThemeData(
splashColor: Colors.transparent,
highlightColor: Colors.transparent,),
child: BottomNavigationBar(
backgroundColor: Colors.transparent,
showUnselectedLabels: false,
showSelectedLabels: false,
type: BottomNavigationBarType.fixed,
elevation: 0,
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(MyFlutterAppHouse.sketch_house,
size: 27.5,), label: (''),),
BottomNavigationBarItem(
icon: Icon(MyFlutterAppOptionsLong.sketch_options_long,
size: 35), label: (''),),
BottomNavigationBarItem(
icon: Icon((MyFlutterAppBook.sketch_book),
size: 34, ), label: (''),),
BottomNavigationBarItem(
icon: Icon(MyFlutterAppSearch.sketch_search,
size: 34), label: (''),),
BottomNavigationBarItem(
icon: Icon(MyFlutterAppPerson.sketch_person,
size: 30.5), label: (''),),
],
currentIndex: _selectedIndex,
onTap: _onItemTap,
unselectedItemColor: Colors.grey[600],
selectedItemColor: Colors.white,
),
),
),
);
}
}
类导航扩展了StatefulWidget{
@凌驾
_NavigationState createState()=>\u NavigationState();
}
类_导航状态扩展状态{
int _selectedIndex=0;
列表_widgetOptions=[
Home(),
选项(),
菜单(),
搜索(),
文本(“配置文件”)
];
无效(整数索引){
设置状态(){
_selectedIndex=索引;
});
}
@凌驾
小部件构建(构建上下文){
返回脚手架(
背景颜色:颜色。透明,
主体:堆栈(
子项:[[u widgetOptions.elementAt(\u selectedIndex)],
),
底部导航栏:容器(
边距:EdgeInsets.zero,
装饰:盒子装饰(
颜色:颜色(0xFF213359),
borderRadius:仅限borderRadius(
左上:半径。圆形(30.0),
右上角:半径。圆形(30.0),),),
儿童:主题(
数据:主题数据(
splashColor:Colors.transparent,
highlightColor:颜色。透明,),
子项:底部导航栏(
背景颜色:颜色。透明,
显示未选择的标签:false,
showSelectedLabels:false,
类型:BottomNavigationBarType.fixed,
海拔:0,
项目:常数[
底部导航气压计(
图标:图标(myflatterapphouse.sketch_house,
尺寸:27.5,),标签:(''),
底部导航气压计(
图标:图标(myflatterAppoptionsLong.sketch\u options\u long,
尺寸:35),标签:(''),
底部导航气压计(
图标:图标((MyAppBook.sketch_book),
尺寸:34,),标签:(''),
底部导航气压计(
图标:图标(myflatterappsearch.sketch\u search,
尺寸:34),标签:(''),
底部导航气压计(
图标:图标(myflatterappperson.sketch\u person,
尺寸:30.5),标签:(''),
],
currentIndex:_selectedIndex,
onTap:\u ONITAP,
unselectedItemColor:颜色。灰色[600],
选择编辑颜色:Colors.white,
),
),
),
);
}
}
是的,脚手架一旦透明,你就会看到黑色的材料, 一个你把颜色放回去的样子,就是这么简单 如果您想从radius gap查看主页,可以将extendBody属性添加到scaffold中
extendBody: true,
啊,那么,我该怎么解决呢?我想让它显示背后的东西,就像我的主页一样我编辑了答案检查,让你的底栏背景与脚手架和家一样。。如果上面的方法不起作用,看看这个-这就是我要找的,谢谢!!