Skip to content

Commit

Permalink
Remove BottomNavigationBarItem.title deprecation (flutter#90295)
Browse files Browse the repository at this point in the history
  • Loading branch information
Piinks authored Oct 14, 2021
1 parent 64b0cfd commit ccc8261
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 90 deletions.
1 change: 0 additions & 1 deletion packages/flutter/lib/src/cupertino/bottom_tab_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ class CupertinoTabBar extends StatelessWidget implements PreferredSizeWidget {
Expanded(
child: Center(child: active ? item.activeIcon : item.icon),
),
if (item.title != null) item.title!,
if (item.label != null) Text(item.label!),
];
}
Expand Down
9 changes: 4 additions & 5 deletions packages/flutter/lib/src/material/bottom_navigation_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,8 @@ class BottomNavigationBar extends StatefulWidget {
}) : assert(items != null),
assert(items.length >= 2),
assert(
items.every((BottomNavigationBarItem item) => item.title != null) ||
items.every((BottomNavigationBarItem item) => item.label != null),
'Every item must have a non-null title or label',
'Every item must have a non-null label',
),
assert(0 <= currentIndex && currentIndex < items.length),
assert(elevation == null || elevation >= 0.0),
Expand Down Expand Up @@ -247,13 +246,13 @@ class BottomNavigationBar extends StatefulWidget {
final double iconSize;

/// The color of the selected [BottomNavigationBarItem.icon] and
/// [BottomNavigationBarItem.title].
/// [BottomNavigationBarItem.label].
///
/// If null then the [ThemeData.primaryColor] is used.
final Color? selectedItemColor;

/// The color of the unselected [BottomNavigationBarItem.icon] and
/// [BottomNavigationBarItem.title]s.
/// [BottomNavigationBarItem.label]s.
///
/// If null then the [ThemeData.unselectedWidgetColor]'s color is used.
final Color? unselectedItemColor;
Expand Down Expand Up @@ -692,7 +691,7 @@ class _Label extends StatelessWidget {
),
),
alignment: Alignment.bottomCenter,
child: item.title ?? Text(item.label!),
child: Text(item.label!),
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ class BottomNavigationBarThemeData with Diagnosticable {
final IconThemeData? unselectedIconTheme;

/// The color of the selected [BottomNavigationBarItem.icon] and
/// [BottomNavigationBarItem.title].
/// [BottomNavigationBarItem.label].
///
/// See [BottomNavigationBar.selectedItemColor].
final Color? selectedItemColor;

/// The color of the unselected [BottomNavigationBarItem.icon] and
/// [BottomNavigationBarItem.title]s.
/// [BottomNavigationBarItem.label]s.
///
/// See [BottomNavigationBar.unselectedItemColor].
final Color? unselectedItemColor;
Expand Down
15 changes: 0 additions & 15 deletions packages/flutter/lib/src/widgets/bottom_navigation_bar_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,11 @@ class BottomNavigationBarItem {
/// The argument [icon] should not be null and the argument [label] should not be null when used in a Material Design's [BottomNavigationBar].
const BottomNavigationBarItem({
required this.icon,
@Deprecated(
'Use "label" instead, as it allows for an improved text-scaling experience. '
'This feature was deprecated after v1.19.0.',
)
this.title,
this.label,
Widget? activeIcon,
this.backgroundColor,
this.tooltip,
}) : activeIcon = activeIcon ?? icon,
assert(label == null || title == null),
assert(icon != null);

/// The icon of the item.
Expand Down Expand Up @@ -67,15 +61,6 @@ class BottomNavigationBarItem {
/// * [BottomNavigationBarItem.icon], for a description of how to pair icons.
final Widget activeIcon;

/// The title of the item. If the title is not provided only the icon will be shown when not used in a Material Design [BottomNavigationBar].
///
/// This field is deprecated, use [label] instead.
@Deprecated(
'Use "label" instead, as it allows for an improved text-scaling experience. '
'This feature was deprecated after v1.19.0.',
)
final Widget? title;

/// The text label for this [BottomNavigationBarItem].
///
/// This will be used to create a [Text] widget to put in the bottom navigation bar.
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/cupertino/bottom_tab_bar_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ Future<void> main() async {
semantics.dispose();
});

testWidgets('Title of items should be nullable', (WidgetTester tester) async {
testWidgets('Label of items should be nullable', (WidgetTester tester) async {
final MemoryImage iconProvider = MemoryImage(Uint8List.fromList(kTransparentImage));
final List<int> itemsTapped = <int>[];

Expand Down
Loading

0 comments on commit ccc8261

Please sign in to comment.