Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
08e38cf2
Unverified
Commit
08e38cf2
authored
Feb 23, 2021
by
Jonathan Cole
Committed by
GitHub
Feb 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix BottomNavigationBar MediaQuery padding (#75360)
parent
c7ecd3fd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
26 deletions
+50
-26
bottom_navigation_bar.dart
packages/flutter/lib/src/material/bottom_navigation_bar.dart
+1
-3
bottom_navigation_bar_test.dart
...ges/flutter/test/material/bottom_navigation_bar_test.dart
+29
-3
floating_action_button_location_test.dart
...r/test/material/floating_action_button_location_test.dart
+20
-20
No files found.
packages/flutter/lib/src/material/bottom_navigation_bar.dart
View file @
08e38cf2
...
...
@@ -1018,9 +1018,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> 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
:
...
...
packages/flutter/test/material/bottom_navigation_bar_test.dart
View file @
08e38cf2
...
...
@@ -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
>[
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
);
});
...
...
packages/flutter/test/material/floating_action_button_location_test.dart
View file @
08e38cf2
...
...
@@ -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
,
42
9.0
,
72.0
,
485
.0
);
const
Rect
bottomNavigationBarRect
=
Rect
.
fromLTRB
(
16.0
,
42
2.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
,
4
41.0
,
60.0
,
489
.0
);
const
Rect
bottomNavigationBarRect
=
Rect
.
fromLTRB
(
12.0
,
4
34.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
,
42
9.0
,
428.0
,
485
.0
);
const
Rect
bottomNavigationBarRect
=
Rect
.
fromLTRB
(
372.0
,
42
2.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
,
4
41.0
,
424.0
,
489
.0
);
const
Rect
bottomNavigationBarRect
=
Rect
.
fromLTRB
(
376.0
,
4
34.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
,
42
9.0
,
784.0
,
485
.0
);
const
Rect
bottomNavigationBarRect
=
Rect
.
fromLTRB
(
728.0
,
42
2.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
,
4
41.0
,
788.0
,
489
.0
);
const
Rect
bottomNavigationBarRect
=
Rect
.
fromLTRB
(
740.0
,
4
34.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
,
4
73.0
,
72.0
,
529
.0
);
const
Rect
bottomNavigationBarRect
=
Rect
.
fromLTRB
(
16.0
,
4
66.0
,
72.0
,
522
.0
);
// Positioned relative to BottomNavigationBar & BottomSheet
const
Rect
bottomSheetRect
=
Rect
.
fromLTRB
(
16.0
,
3
73.0
,
72.0
,
429
.0
);
const
Rect
bottomSheetRect
=
Rect
.
fromLTRB
(
16.0
,
3
66.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
,
47
7.0
,
60.0
,
525
.0
);
const
Rect
bottomNavigationBarRect
=
Rect
.
fromLTRB
(
12.0
,
47
0.0
,
60.0
,
518
.0
);
// Positioned relative to BottomNavigationBar & BottomSheet
const
Rect
bottomSheetRect
=
Rect
.
fromLTRB
(
12.0
,
37
7.0
,
60.0
,
425
.0
);
const
Rect
bottomSheetRect
=
Rect
.
fromLTRB
(
12.0
,
37
0.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
,
4
73.0
,
428.0
,
529
.0
);
const
Rect
bottomNavigationBarRect
=
Rect
.
fromLTRB
(
372.0
,
4
66.0
,
428.0
,
522
.0
);
// Positioned relative to BottomNavigationBar & BottomSheet
const
Rect
bottomSheetRect
=
Rect
.
fromLTRB
(
372.0
,
3
73.0
,
428.0
,
429
.0
);
const
Rect
bottomSheetRect
=
Rect
.
fromLTRB
(
372.0
,
3
66.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
,
47
7.0
,
424.0
,
525
.0
);
const
Rect
bottomNavigationBarRect
=
Rect
.
fromLTRB
(
376.0
,
47
0.0
,
424.0
,
518
.0
);
// Positioned relative to BottomNavigationBar & BottomSheet
const
Rect
bottomSheetRect
=
Rect
.
fromLTRB
(
376.0
,
37
7.0
,
424.0
,
425
.0
);
const
Rect
bottomSheetRect
=
Rect
.
fromLTRB
(
376.0
,
37
0.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
,
4
73.0
,
784.0
,
529
.0
);
const
Rect
bottomNavigationBarRect
=
Rect
.
fromLTRB
(
728.0
,
4
66.0
,
784.0
,
522
.0
);
// Positioned relative to BottomNavigationBar & BottomSheet
const
Rect
bottomSheetRect
=
Rect
.
fromLTRB
(
728.0
,
3
73.0
,
784.0
,
429
.0
);
const
Rect
bottomSheetRect
=
Rect
.
fromLTRB
(
728.0
,
3
66.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
,
47
7.0
,
788.0
,
525
.0
);
const
Rect
bottomNavigationBarRect
=
Rect
.
fromLTRB
(
740.0
,
47
0.0
,
788.0
,
518
.0
);
// Positioned relative to BottomNavigationBar & BottomSheet
const
Rect
bottomSheetRect
=
Rect
.
fromLTRB
(
740.0
,
37
7.0
,
788.0
,
425
.0
);
const
Rect
bottomSheetRect
=
Rect
.
fromLTRB
(
740.0
,
37
0.0
,
788.0
,
418
.0
);
// Positioned relative to SnackBar
const
Rect
snackBarRect
=
Rect
.
fromLTRB
(
740.0
,
494.0
,
788.0
,
542.0
);
await
_runDockedTests
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment