Fix BottomNavigationBarItem tooltip defaults to label (#107715)

This commit is contained in:
Bruno Leroux 2022-07-21 06:21:05 +02:00 committed by GitHub
parent ebb9128fd5
commit d263cfbcb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 7 deletions

View File

@ -455,7 +455,7 @@ class _BottomNavigationTile extends StatelessWidget {
final double unselectedIconDiff = math.max(unselectedIconSize - selectedIconSize, 0);
// The effective tool tip message to be shown on the BottomNavigationBarItem.
final String? effectiveTooltip = item.tooltip == '' ? null : item.tooltip ?? item.label;
final String? effectiveTooltip = item.tooltip == '' ? null : item.tooltip;
// Defines the padding for the animating icons + labels.
//

View File

@ -81,12 +81,10 @@ class BottomNavigationBarItem {
/// the icons themselves.
final Color? backgroundColor;
/// The text to display in the tooltip for this [BottomNavigationBarItem], when
/// the user long presses the item.
/// The text to display in the [Tooltip] for this [BottomNavigationBarItem].
///
/// The [Tooltip] will only appear on an item in a Material design [BottomNavigationBar], and
/// when the string is not empty.
/// A [Tooltip] will only appear on this item if `tooltip` is set to a non-empty string.
///
/// Defaults to null, in which case the [label] text will be used.
/// Defaults to null, in which case the tooltip is not shown.
final String? tooltip;
}

View File

@ -1209,7 +1209,7 @@ void main() {
expect(find.text('B'), findsOneWidget);
await tester.longPress(find.text('B'));
expect(find.byTooltip('B'), findsOneWidget);
expect(find.byTooltip('B'), findsNothing);
expect(find.text('C'), findsOneWidget);
await tester.longPress(find.text('C'));