gpt4 book ai didi

flutter - BottomNavigationBar 标题未显示在 Flutter 中

转载 作者:IT王子 更新时间:2023-10-29 06:55:51 27 4
gpt4 key购买 nike

为什么底部导航栏标题不显示?它应该显示在图标下方

class FlutterProject extends StatefulWidget {
final String title = "Flutter Bottom Tab demo";

@override
GoalsListState createState() {
return GoalsListState();
}
}

class GoalsListState extends State<FlutterProject>
with SingleTickerProviderStateMixin {
int _cIndex = 0;

void _incrementTab(index) {
setState(() {
_cIndex = index;
});
}

final List<Widget> _children = [
new One(),
new Two(),
new Three(),
new Four(),
new More()
];

@override
Widget build(BuildContext context) {
return new Scaffold(
body: _children[_cIndex],
bottomNavigationBar: BottomNavigationBar(
currentIndex: _cIndex,
type: BottomNavigationBarType.shifting,
items: [
BottomNavigationBarItem(
icon:
Icon(Icons.graphic_eq, color: Color.fromARGB(255, 0, 0, 0)),
title: new Text('One')),
BottomNavigationBarItem(
icon: Icon(Icons.report_problem,
color: Color.fromARGB(255, 0, 0, 0)),
title: new Text('Two')),
BottomNavigationBarItem(
icon: Icon(Icons.work, color: Color.fromARGB(255, 0, 0, 0)),
title: new Text('Three')),
BottomNavigationBarItem(
icon: Icon(Icons.domain, color: Color.fromARGB(255, 0, 0, 0)),
title: new Text('Four')),
BottomNavigationBarItem(
icon: Icon(Icons.menu, color: Color.fromARGB(255, 0, 0, 0)),
title: new Text('Five')),
],
onTap: (index) {
_incrementTab(index);
},
));
}
}

我在这里错过了什么?

最佳答案

当提供超过 3 个 BottomNavigationBar 项目时,如果未指定类型,则根据 https://docs.flutter.io/flutter/material/BottomNavigationBar/BottomNavigationBar.html 更改为 BottomNavigationBarType.shifting .这条信息应该在类(class)的文档中突出显示。很容易忽略它的位置(我忽略了它)。

添加类型:BottomNavigationBarType.fixed on BottomNavigationBar

BottomNavigationBar(
type: BottomNavigationBarType.fixed,
items: <BottomNavigationBarItem>[],
)

关于flutter - BottomNavigationBar 标题未显示在 Flutter 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57492720/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com