diff --git a/packages/flutter/lib/src/material/bottom_navigation_bar.dart b/packages/flutter/lib/src/material/bottom_navigation_bar.dart index 9d95248c5c8..90ebe07e4bc 100644 --- a/packages/flutter/lib/src/material/bottom_navigation_bar.dart +++ b/packages/flutter/lib/src/material/bottom_navigation_bar.dart @@ -1018,9 +1018,7 @@ class _BottomNavigationBarState extends State with TickerPr assert(Overlay.of(context, debugRequiredFor: widget) != null); final BottomNavigationBarThemeData bottomTheme = BottomNavigationBarTheme.of(context); - - // Labels apply up to _bottomMargin padding. Remainder is media padding. - final double additionalBottomPadding = math.max(MediaQuery.of(context).padding.bottom - widget.selectedFontSize / 2.0, 0.0); + final double additionalBottomPadding = MediaQuery.of(context).padding.bottom; Color? backgroundColor; switch (_effectiveType) { case BottomNavigationBarType.fixed: diff --git a/packages/flutter/test/material/bottom_navigation_bar_test.dart b/packages/flutter/test/material/bottom_navigation_bar_test.dart index 09634afbe7c..2756d8a1fa3 100644 --- a/packages/flutter/test/material/bottom_navigation_bar_test.dart +++ b/packages/flutter/test/material/bottom_navigation_bar_test.dart @@ -721,9 +721,35 @@ void main() { ), ); - const double labelBottomMargin = 7.0; // 7 == defaulted selectedFontSize / 2.0. - const double additionalPadding = 40.0 - labelBottomMargin; - const double expectedHeight = kBottomNavigationBarHeight + additionalPadding; + const double expectedHeight = kBottomNavigationBarHeight + 40.0; + expect(tester.getSize(find.byType(BottomNavigationBar)).height, expectedHeight); + }); + + testWidgets('BottomNavigationBar adds bottom padding to height with a custom font size', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + home: MediaQuery( + data: const MediaQueryData(padding: EdgeInsets.only(bottom: 40.0)), + child: Scaffold( + bottomNavigationBar: BottomNavigationBar( + selectedFontSize: 8, + items: const [ + BottomNavigationBarItem( + icon: Icon(Icons.ac_unit), + label: 'AC', + ), + BottomNavigationBarItem( + icon: Icon(Icons.access_alarm), + label: 'Alarm', + ), + ], + ), + ), + ), + ), + ); + + const double expectedHeight = kBottomNavigationBarHeight + 40.0; expect(tester.getSize(find.byType(BottomNavigationBar)).height, expectedHeight); }); diff --git a/packages/flutter/test/material/floating_action_button_location_test.dart b/packages/flutter/test/material/floating_action_button_location_test.dart index 35d94cf0c6f..67955a895e8 100644 --- a/packages/flutter/test/material/floating_action_button_location_test.dart +++ b/packages/flutter/test/material/floating_action_button_location_test.dart @@ -684,7 +684,7 @@ void main() { const double keyboardHeight = 200.0; const double viewPadding = 50.0; final Key floatingActionButton = UniqueKey(); - const double bottomNavHeight = 99.0; + const double bottomNavHeight = 106.0; // Default await tester.pumpWidget(_buildTest( location, @@ -929,7 +929,7 @@ void main() { testWidgets('startFloat', (WidgetTester tester) async { const Rect defaultRect = Rect.fromLTRB(16.0, 478.0, 72.0, 534.0); // Positioned relative to BottomNavigationBar - const Rect bottomNavigationBarRect = Rect.fromLTRB(16.0, 429.0, 72.0, 485.0); + const Rect bottomNavigationBarRect = Rect.fromLTRB(16.0, 422.0, 72.0, 478.0); // Position relative to BottomSheet const Rect bottomSheetRect = Rect.fromLTRB(16.0, 472.0, 72.0, 528.0); // Positioned relative to SnackBar @@ -947,7 +947,7 @@ void main() { testWidgets('miniStartFloat', (WidgetTester tester) async { const Rect defaultRect = Rect.fromLTRB(12.0, 490.0, 60.0, 538.0); // Positioned relative to BottomNavigationBar - const Rect bottomNavigationBarRect = Rect.fromLTRB(12.0, 441.0, 60.0, 489.0); + const Rect bottomNavigationBarRect = Rect.fromLTRB(12.0, 434.0, 60.0, 482.0); // Positioned relative to BottomSheet const Rect bottomSheetRect = Rect.fromLTRB(12.0, 480.0, 60.0, 528.0); // Positioned relative to SnackBar @@ -966,7 +966,7 @@ void main() { testWidgets('centerFloat', (WidgetTester tester) async { const Rect defaultRect = Rect.fromLTRB(372.0, 478.0, 428.0, 534.0); // Positioned relative to BottomNavigationBar - const Rect bottomNavigationBarRect = Rect.fromLTRB(372.0, 429.0, 428.0, 485.0); + const Rect bottomNavigationBarRect = Rect.fromLTRB(372.0, 422.0, 428.0, 478.0); // Positioned relative to BottomSheet const Rect bottomSheetRect = Rect.fromLTRB(372.0, 472.0, 428.0, 528.0); // Positioned relative to SnackBar @@ -984,7 +984,7 @@ void main() { testWidgets('miniCenterFloat', (WidgetTester tester) async { const Rect defaultRect = Rect.fromLTRB(376.0, 490.0, 424.0, 538.0); // Positioned relative to BottomNavigationBar - const Rect bottomNavigationBarRect = Rect.fromLTRB(376.0, 441.0, 424.0, 489.0); + const Rect bottomNavigationBarRect = Rect.fromLTRB(376.0, 434.0, 424.0, 482.0); // Positioned relative to BottomSheet const Rect bottomSheetRect = Rect.fromLTRB(376.0, 480.0, 424.0, 528.0); // Positioned relative to SnackBar @@ -1003,7 +1003,7 @@ void main() { testWidgets('endFloat', (WidgetTester tester) async { const Rect defaultRect = Rect.fromLTRB(728.0, 478.0, 784.0, 534.0); // Positioned relative to BottomNavigationBar - const Rect bottomNavigationBarRect = Rect.fromLTRB(728.0, 429.0, 784.0, 485.0); + const Rect bottomNavigationBarRect = Rect.fromLTRB(728.0, 422.0, 784.0, 478.0); // Positioned relative to BottomSheet const Rect bottomSheetRect = Rect.fromLTRB(728.0, 472.0, 784.0, 528.0); // Positioned relative to SnackBar @@ -1021,7 +1021,7 @@ void main() { testWidgets('miniEndFloat', (WidgetTester tester) async { const Rect defaultRect = Rect.fromLTRB(740.0, 490.0, 788.0, 538.0); // Positioned relative to BottomNavigationBar - const Rect bottomNavigationBarRect = Rect.fromLTRB(740.0, 441.0, 788.0, 489.0); + const Rect bottomNavigationBarRect = Rect.fromLTRB(740.0, 434.0, 788.0, 482.0); // Positioned relative to BottomSheet const Rect bottomSheetRect = Rect.fromLTRB(740.0, 480.0, 788.0, 528.0); // Positioned relative to SnackBar @@ -1056,7 +1056,7 @@ void main() { }) async { const double keyboardHeight = 200.0; const double viewPadding = 50.0; - const double bottomNavHeight = 99.0; + const double bottomNavHeight = 106.0; final Key floatingActionButton = UniqueKey(); final double fabHeight = mini ? 48.0 : 56.0; // Default @@ -1269,9 +1269,9 @@ void main() { testWidgets('startDocked', (WidgetTester tester) async { const Rect defaultRect = Rect.fromLTRB(16.0, 494.0, 72.0, 550.0); // Positioned relative to BottomNavigationBar - const Rect bottomNavigationBarRect = Rect.fromLTRB(16.0, 473.0, 72.0, 529.0); + const Rect bottomNavigationBarRect = Rect.fromLTRB(16.0, 466.0, 72.0, 522.0); // Positioned relative to BottomNavigationBar & BottomSheet - const Rect bottomSheetRect = Rect.fromLTRB(16.0, 373.0, 72.0, 429.0); + const Rect bottomSheetRect = Rect.fromLTRB(16.0, 366.0, 72.0, 422.0); // Positioned relative to SnackBar const Rect snackBarRect = Rect.fromLTRB(16.0, 486.0, 72.0, 542.0); await _runDockedTests( @@ -1287,9 +1287,9 @@ void main() { testWidgets('miniStartDocked', (WidgetTester tester) async { const Rect defaultRect = Rect.fromLTRB(12.0, 502.0, 60.0, 550.0); // Positioned relative to BottomNavigationBar - const Rect bottomNavigationBarRect = Rect.fromLTRB(12.0, 477.0, 60.0, 525.0); + const Rect bottomNavigationBarRect = Rect.fromLTRB(12.0, 470.0, 60.0, 518.0); // Positioned relative to BottomNavigationBar & BottomSheet - const Rect bottomSheetRect = Rect.fromLTRB(12.0, 377.0, 60.0, 425.0); + const Rect bottomSheetRect = Rect.fromLTRB(12.0, 370.0, 60.0, 418.0); // Positioned relative to SnackBar const Rect snackBarRect = Rect.fromLTRB(12.0, 494.0, 60.0, 542.0); await _runDockedTests( @@ -1306,9 +1306,9 @@ void main() { testWidgets('centerDocked', (WidgetTester tester) async { const Rect defaultRect = Rect.fromLTRB(372.0, 494.0, 428.0, 550.0); // Positioned relative to BottomNavigationBar - const Rect bottomNavigationBarRect = Rect.fromLTRB(372.0, 473.0, 428.0, 529.0); + const Rect bottomNavigationBarRect = Rect.fromLTRB(372.0, 466.0, 428.0, 522.0); // Positioned relative to BottomNavigationBar & BottomSheet - const Rect bottomSheetRect = Rect.fromLTRB(372.0, 373.0, 428.0, 429.0); + const Rect bottomSheetRect = Rect.fromLTRB(372.0, 366.0, 428.0, 422.0); // Positioned relative to SnackBar const Rect snackBarRect = Rect.fromLTRB(372.0, 486.0, 428.0, 542.0); await _runDockedTests( @@ -1324,9 +1324,9 @@ void main() { testWidgets('miniCenterDocked', (WidgetTester tester) async { const Rect defaultRect = Rect.fromLTRB(376.0, 502.0, 424.0, 550.0); // Positioned relative to BottomNavigationBar - const Rect bottomNavigationBarRect = Rect.fromLTRB(376.0, 477.0, 424.0, 525.0); + const Rect bottomNavigationBarRect = Rect.fromLTRB(376.0, 470.0, 424.0, 518.0); // Positioned relative to BottomNavigationBar & BottomSheet - const Rect bottomSheetRect = Rect.fromLTRB(376.0, 377.0, 424.0, 425.0); + const Rect bottomSheetRect = Rect.fromLTRB(376.0, 370.0, 424.0, 418.0); // Positioned relative to SnackBar const Rect snackBarRect = Rect.fromLTRB(376.0, 494.0, 424.0, 542.0); await _runDockedTests( @@ -1343,9 +1343,9 @@ void main() { testWidgets('endDocked', (WidgetTester tester) async { const Rect defaultRect = Rect.fromLTRB(728.0, 494.0, 784.0, 550.0); // Positioned relative to BottomNavigationBar - const Rect bottomNavigationBarRect = Rect.fromLTRB(728.0, 473.0, 784.0, 529.0); + const Rect bottomNavigationBarRect = Rect.fromLTRB(728.0, 466.0, 784.0, 522.0); // Positioned relative to BottomNavigationBar & BottomSheet - const Rect bottomSheetRect = Rect.fromLTRB(728.0, 373.0, 784.0, 429.0); + const Rect bottomSheetRect = Rect.fromLTRB(728.0, 366.0, 784.0, 422.0); // Positioned relative to SnackBar const Rect snackBarRect = Rect.fromLTRB(728.0, 486.0, 784.0, 542.0); await _runDockedTests( @@ -1361,9 +1361,9 @@ void main() { testWidgets('miniEndDocked', (WidgetTester tester) async { const Rect defaultRect = Rect.fromLTRB(740.0, 502.0, 788.0, 550.0); // Positioned relative to BottomNavigationBar - const Rect bottomNavigationBarRect = Rect.fromLTRB(740.0, 477.0, 788.0, 525.0); + const Rect bottomNavigationBarRect = Rect.fromLTRB(740.0, 470.0, 788.0, 518.0); // Positioned relative to BottomNavigationBar & BottomSheet - const Rect bottomSheetRect = Rect.fromLTRB(740.0, 377.0, 788.0, 425.0); + const Rect bottomSheetRect = Rect.fromLTRB(740.0, 370.0, 788.0, 418.0); // Positioned relative to SnackBar const Rect snackBarRect = Rect.fromLTRB(740.0, 494.0, 788.0, 542.0); await _runDockedTests(