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: not yet

References

API documentation:

  • [BottomNavigationBarItem][]

Relevant PR:

  • [Clean up hero controller scope][]

Breaking change proposal:

Stable channel link: [BottomNavigationBarItem]: https://api.flutter-io.cn/flutter/widgets/BottomNavigationBarItem-class.html

Master channel link: [BottomNavigationBarItem]: https://master-api.flutter.dev/flutter/widgets/BottomNavigationBarItem-class.html