英文:
I´ve a problem with the BottomNavigationBar in Flutter . BottomNavigationBarItem: title is not working and there is error
问题
这是发生的错误。
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(
Icons.home,
),
title: Text(
'首页',
),
),
BottomNavigationBarItem(
icon: Icon(
Icons.message,
),
title: Text(
'消息',
),
),
BottomNavigationBarItem(
icon: Icon(
Icons.person,
),
title: Text(
'个人资料',
),
),
],
),
错误代码片段
帮助解决这个问题。
英文:
enter image description herethis is the error occur.
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(
Icons.home,
),
title: Text(
'Home',
),
),
BottomNavigationBarItem(
icon: Icon(
Icons.message,
),
title: Text(
'Messages',
),
),
BottomNavigationBarItem(
icon: Icon(
Icons.person,
),
title: Text(
'Profile',
),
),
],
),
enter image description here error code snippets
help for solve this problem.
答案1
得分: 0
问题是BottomNavigationBarItem
中没有title
属性,而是使用label
。
另外,第一张图片中的错误提示说label
等于null
。
英文:
the problem is that there is no property title
in the BottomNavigationBarItem
, instead use label
also the error in the first picture says, that label is equal to null
答案2
得分: 0
底部导航栏项目中没有名为'title'的参数。您需要使用'label'来为BottomNavigationBarItem小部件提供文本,并直接使用字符串。
因此,更新后的代码将如下所示:
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(
Icons.home,
),
label: '首页',
),
BottomNavigationBarItem(
icon: Icon(
Icons.message,
),
label: '消息',
),
BottomNavigationBarItem(
icon: Icon(
Icons.person,
),
label: '个人资料',
),
],
)
英文:
Bro there's not parameter with name 'title' in the BottomNavigationBarItem. you need to use label for giving the text in the BottomNavigationBarItem widget and it aspects string directly.
So the updated code would look like this:
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(
Icons.home,
),
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(
Icons.message,
),
label: 'Messages',
),
BottomNavigationBarItem(
icon: Icon(
Icons.person,
),
label: 'Profile',
),
],
),
答案3
得分: 0
你应该使用"label"而不是"title"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论