Bottom Navigation Title To Label
Summary
#BottomNavigationBarItem.title gives a deprecation warning,
or no longer exists when referenced in code.
Context
#BottomNavigationBarItems title parameter was deprecated
in favor of label. This change was necessary to improve
the user experience of BottomNavigationBars when the text
scale factor is increased. Items in a BottomNavigationBar
now show tooltips on long press. Accomplishing this
requires a String parameter on BottomNavigationBarItems.
Description of change
#The BottomNavigationBarItem class has a title parameter,
which is a Widget. This made it impossible for the
BottomNavigationBar to show Tooltip widgets,
a change that was necessary to improve the accessibility experience.
Now, instead of building the BottomNavigationBarItem.title
widget, the BottomNavigationBar wraps the
BottomNavigationBarItem.label in a Text widget and builds that.
Migration guide
#Code before migration:
BottomNavigationBarItem(
icon: Icons.add,
title: Text('add'),
)Code after migration:
BottomNavigationBarItem(
icon: Icons.add,
label: 'add',
)Timeline
#Landed in version: 1.22.0
In stable release: 2.0.0
References
#API documentation:
Relevant PRs:
- PR 60655: Clean up hero controller scope
- PR 59127: Update BottomNavigationBar to show tooltips on long press.
Breaking change proposal:
除非另有说明,本文档之所提及适用于 Flutter 的最新稳定版本,本页面最后更新时间: 2024-12-16。 查看文档源码 或者 为本页面内容提出建议.