Agu*_*ana 3 flutter flutter-bottomnavigation
如果我长按底部导航栏项目的某个项目,那么它将显示一个弹出窗口/吐司及其项目的标题(上图中的收件箱弹出窗口)。我想禁用该行为,该怎么做?
这是我当前的底部导航栏
BottomNavigationBar(
onTap: _selectPage,
elevation: 2,
backgroundColor: const Color.fromRGBO(245, 245, 245, 1),
unselectedItemColor: Colors.grey,
selectedItemColor: Theme.of(context).primaryColor,
currentIndex: _selectedPageIndex,
showSelectedLabels: false,
showUnselectedLabels: false,
type: BottomNavigationBarType.fixed,
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home_outlined),
label: "Home",
),
BottomNavigationBarItem(
icon: Icon(Icons.search),
label: "Search",
),
BottomNavigationBarItem(
icon: Icon(Icons.add_circle_outline),
label: "create",
),
BottomNavigationBarItem(
icon: Icon(Icons.notifications_none),
label: "Inbox",
),
BottomNavigationBarItem(
icon: Icon(Icons.person_outline),
label: "Profile",
),
],
),
Run Code Online (Sandbox Code Playgroud)
只需传递一个空字符串tooltip
,它就会停止显示弹出窗口。这是您更新的代码:
BottomNavigationBar(
onTap: _selectPage,
elevation: 2,
backgroundColor: const Color.fromRGBO(245, 245, 245, 1),
unselectedItemColor: Colors.grey,
selectedItemColor: Theme.of(context).primaryColor,
currentIndex: _selectedPageIndex,
showSelectedLabels: false,
showUnselectedLabels: false,
type: BottomNavigationBarType.fixed,
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home_outlined),
label: "Home",
tooltip: '',
),
BottomNavigationBarItem(
icon: Icon(Icons.search),
label: "Search",
tooltip: '',
),
BottomNavigationBarItem(
icon: Icon(Icons.add_circle_outline),
label: "create",
tooltip: '',
),
BottomNavigationBarItem(
icon: Icon(Icons.notifications_none),
label: "Inbox",
tooltip: '',
),
BottomNavigationBarItem(
icon: Icon(Icons.person_outline),
label: "Profile",
tooltip: '',
),
],
),
Run Code Online (Sandbox Code Playgroud)
几个月前,这个问题在 github 上被提出,请参考https://github.com/flutter/flutter/issues/71049#:~:text=BottomNavigationBar%20has%20no%20API%20for,to%20completely%20disable %20its%20tooltips。
归档时间: |
|
查看次数: |
1749 次 |
最近记录: |