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
fd360c4a
Unverified
Commit
fd360c4a
authored
Apr 18, 2022
by
Eric egramond
Committed by
GitHub
Apr 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent Mediaquery from losing navigationMode value when removePadding() is called (#101938)
parent
7b7206e9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
43 deletions
+18
-43
media_query.dart
packages/flutter/lib/src/widgets/media_query.dart
+3
-42
media_query_test.dart
packages/flutter/test/widgets/media_query_test.dart
+15
-1
No files found.
packages/flutter/lib/src/widgets/media_query.dart
View file @
fd360c4a
...
@@ -438,11 +438,7 @@ class MediaQueryData {
...
@@ -438,11 +438,7 @@ class MediaQueryData {
})
{
})
{
if
(!(
removeLeft
||
removeTop
||
removeRight
||
removeBottom
))
if
(!(
removeLeft
||
removeTop
||
removeRight
||
removeBottom
))
return
this
;
return
this
;
return
MediaQueryData
(
return
copyWith
(
size:
size
,
devicePixelRatio:
devicePixelRatio
,
textScaleFactor:
textScaleFactor
,
platformBrightness:
platformBrightness
,
padding:
padding
.
copyWith
(
padding:
padding
.
copyWith
(
left:
removeLeft
?
0.0
:
null
,
left:
removeLeft
?
0.0
:
null
,
top:
removeTop
?
0.0
:
null
,
top:
removeTop
?
0.0
:
null
,
...
@@ -455,15 +451,6 @@ class MediaQueryData {
...
@@ -455,15 +451,6 @@ class MediaQueryData {
right:
removeRight
?
math
.
max
(
0.0
,
viewPadding
.
right
-
padding
.
right
)
:
null
,
right:
removeRight
?
math
.
max
(
0.0
,
viewPadding
.
right
-
padding
.
right
)
:
null
,
bottom:
removeBottom
?
math
.
max
(
0.0
,
viewPadding
.
bottom
-
padding
.
bottom
)
:
null
,
bottom:
removeBottom
?
math
.
max
(
0.0
,
viewPadding
.
bottom
-
padding
.
bottom
)
:
null
,
),
),
viewInsets:
viewInsets
,
alwaysUse24HourFormat:
alwaysUse24HourFormat
,
highContrast:
highContrast
,
disableAnimations:
disableAnimations
,
invertColors:
invertColors
,
accessibleNavigation:
accessibleNavigation
,
boldText:
boldText
,
gestureSettings:
gestureSettings
,
displayFeatures:
displayFeatures
,
);
);
}
}
...
@@ -488,12 +475,7 @@ class MediaQueryData {
...
@@ -488,12 +475,7 @@ class MediaQueryData {
})
{
})
{
if
(!(
removeLeft
||
removeTop
||
removeRight
||
removeBottom
))
if
(!(
removeLeft
||
removeTop
||
removeRight
||
removeBottom
))
return
this
;
return
this
;
return
MediaQueryData
(
return
copyWith
(
size:
size
,
devicePixelRatio:
devicePixelRatio
,
textScaleFactor:
textScaleFactor
,
platformBrightness:
platformBrightness
,
padding:
padding
,
viewPadding:
viewPadding
.
copyWith
(
viewPadding:
viewPadding
.
copyWith
(
left:
removeLeft
?
math
.
max
(
0.0
,
viewPadding
.
left
-
viewInsets
.
left
)
:
null
,
left:
removeLeft
?
math
.
max
(
0.0
,
viewPadding
.
left
-
viewInsets
.
left
)
:
null
,
top:
removeTop
?
math
.
max
(
0.0
,
viewPadding
.
top
-
viewInsets
.
top
)
:
null
,
top:
removeTop
?
math
.
max
(
0.0
,
viewPadding
.
top
-
viewInsets
.
top
)
:
null
,
...
@@ -506,14 +488,6 @@ class MediaQueryData {
...
@@ -506,14 +488,6 @@ class MediaQueryData {
right:
removeRight
?
0.0
:
null
,
right:
removeRight
?
0.0
:
null
,
bottom:
removeBottom
?
0.0
:
null
,
bottom:
removeBottom
?
0.0
:
null
,
),
),
alwaysUse24HourFormat:
alwaysUse24HourFormat
,
highContrast:
highContrast
,
disableAnimations:
disableAnimations
,
invertColors:
invertColors
,
accessibleNavigation:
accessibleNavigation
,
boldText:
boldText
,
gestureSettings:
gestureSettings
,
displayFeatures:
displayFeatures
,
);
);
}
}
...
@@ -538,32 +512,19 @@ class MediaQueryData {
...
@@ -538,32 +512,19 @@ class MediaQueryData {
})
{
})
{
if
(!(
removeLeft
||
removeTop
||
removeRight
||
removeBottom
))
if
(!(
removeLeft
||
removeTop
||
removeRight
||
removeBottom
))
return
this
;
return
this
;
return
MediaQueryData
(
return
copyWith
(
size:
size
,
devicePixelRatio:
devicePixelRatio
,
textScaleFactor:
textScaleFactor
,
platformBrightness:
platformBrightness
,
padding:
padding
.
copyWith
(
padding:
padding
.
copyWith
(
left:
removeLeft
?
0.0
:
null
,
left:
removeLeft
?
0.0
:
null
,
top:
removeTop
?
0.0
:
null
,
top:
removeTop
?
0.0
:
null
,
right:
removeRight
?
0.0
:
null
,
right:
removeRight
?
0.0
:
null
,
bottom:
removeBottom
?
0.0
:
null
,
bottom:
removeBottom
?
0.0
:
null
,
),
),
viewInsets:
viewInsets
,
viewPadding:
viewPadding
.
copyWith
(
viewPadding:
viewPadding
.
copyWith
(
left:
removeLeft
?
0.0
:
null
,
left:
removeLeft
?
0.0
:
null
,
top:
removeTop
?
0.0
:
null
,
top:
removeTop
?
0.0
:
null
,
right:
removeRight
?
0.0
:
null
,
right:
removeRight
?
0.0
:
null
,
bottom:
removeBottom
?
0.0
:
null
,
bottom:
removeBottom
?
0.0
:
null
,
),
),
alwaysUse24HourFormat:
alwaysUse24HourFormat
,
highContrast:
highContrast
,
disableAnimations:
disableAnimations
,
invertColors:
invertColors
,
accessibleNavigation:
accessibleNavigation
,
boldText:
boldText
,
gestureSettings:
gestureSettings
,
displayFeatures:
displayFeatures
,
);
);
}
}
...
...
packages/flutter/test/widgets/media_query_test.dart
View file @
fd360c4a
...
@@ -171,6 +171,7 @@ void main() {
...
@@ -171,6 +171,7 @@ void main() {
boldText:
true
,
boldText:
true
,
highContrast:
true
,
highContrast:
true
,
platformBrightness:
Brightness
.
dark
,
platformBrightness:
Brightness
.
dark
,
navigationMode:
NavigationMode
.
directional
,
gestureSettings:
gestureSettings
,
gestureSettings:
gestureSettings
,
displayFeatures:
customDisplayFeatures
,
displayFeatures:
customDisplayFeatures
,
);
);
...
@@ -188,6 +189,7 @@ void main() {
...
@@ -188,6 +189,7 @@ void main() {
expect
(
copied
.
boldText
,
true
);
expect
(
copied
.
boldText
,
true
);
expect
(
copied
.
highContrast
,
true
);
expect
(
copied
.
highContrast
,
true
);
expect
(
copied
.
platformBrightness
,
Brightness
.
dark
);
expect
(
copied
.
platformBrightness
,
Brightness
.
dark
);
expect
(
copied
.
navigationMode
,
NavigationMode
.
directional
);
expect
(
copied
.
gestureSettings
,
gestureSettings
);
expect
(
copied
.
gestureSettings
,
gestureSettings
);
expect
(
copied
.
displayFeatures
,
customDisplayFeatures
);
expect
(
copied
.
displayFeatures
,
customDisplayFeatures
);
});
});
...
@@ -223,6 +225,7 @@ void main() {
...
@@ -223,6 +225,7 @@ void main() {
disableAnimations:
true
,
disableAnimations:
true
,
boldText:
true
,
boldText:
true
,
highContrast:
true
,
highContrast:
true
,
navigationMode:
NavigationMode
.
directional
,
displayFeatures:
displayFeatures
,
displayFeatures:
displayFeatures
,
),
),
child:
Builder
(
child:
Builder
(
...
@@ -257,6 +260,7 @@ void main() {
...
@@ -257,6 +260,7 @@ void main() {
expect
(
unpadded
.
disableAnimations
,
true
);
expect
(
unpadded
.
disableAnimations
,
true
);
expect
(
unpadded
.
boldText
,
true
);
expect
(
unpadded
.
boldText
,
true
);
expect
(
unpadded
.
highContrast
,
true
);
expect
(
unpadded
.
highContrast
,
true
);
expect
(
unpadded
.
navigationMode
,
NavigationMode
.
directional
);
expect
(
unpadded
.
displayFeatures
,
displayFeatures
);
expect
(
unpadded
.
displayFeatures
,
displayFeatures
);
});
});
...
@@ -291,6 +295,7 @@ void main() {
...
@@ -291,6 +295,7 @@ void main() {
disableAnimations:
true
,
disableAnimations:
true
,
boldText:
true
,
boldText:
true
,
highContrast:
true
,
highContrast:
true
,
navigationMode:
NavigationMode
.
directional
,
displayFeatures:
displayFeatures
,
displayFeatures:
displayFeatures
,
),
),
child:
Builder
(
child:
Builder
(
...
@@ -322,6 +327,7 @@ void main() {
...
@@ -322,6 +327,7 @@ void main() {
expect
(
unpadded
.
disableAnimations
,
true
);
expect
(
unpadded
.
disableAnimations
,
true
);
expect
(
unpadded
.
boldText
,
true
);
expect
(
unpadded
.
boldText
,
true
);
expect
(
unpadded
.
highContrast
,
true
);
expect
(
unpadded
.
highContrast
,
true
);
expect
(
unpadded
.
navigationMode
,
NavigationMode
.
directional
);
expect
(
unpadded
.
displayFeatures
,
displayFeatures
);
expect
(
unpadded
.
displayFeatures
,
displayFeatures
);
});
});
...
@@ -356,6 +362,7 @@ void main() {
...
@@ -356,6 +362,7 @@ void main() {
disableAnimations:
true
,
disableAnimations:
true
,
boldText:
true
,
boldText:
true
,
highContrast:
true
,
highContrast:
true
,
navigationMode:
NavigationMode
.
directional
,
displayFeatures:
displayFeatures
,
displayFeatures:
displayFeatures
,
),
),
child:
Builder
(
child:
Builder
(
...
@@ -390,6 +397,7 @@ void main() {
...
@@ -390,6 +397,7 @@ void main() {
expect
(
unpadded
.
disableAnimations
,
true
);
expect
(
unpadded
.
disableAnimations
,
true
);
expect
(
unpadded
.
boldText
,
true
);
expect
(
unpadded
.
boldText
,
true
);
expect
(
unpadded
.
highContrast
,
true
);
expect
(
unpadded
.
highContrast
,
true
);
expect
(
unpadded
.
navigationMode
,
NavigationMode
.
directional
);
expect
(
unpadded
.
displayFeatures
,
displayFeatures
);
expect
(
unpadded
.
displayFeatures
,
displayFeatures
);
});
});
...
@@ -424,6 +432,7 @@ void main() {
...
@@ -424,6 +432,7 @@ void main() {
disableAnimations:
true
,
disableAnimations:
true
,
boldText:
true
,
boldText:
true
,
highContrast:
true
,
highContrast:
true
,
navigationMode:
NavigationMode
.
directional
,
displayFeatures:
displayFeatures
,
displayFeatures:
displayFeatures
,
),
),
child:
Builder
(
child:
Builder
(
...
@@ -455,6 +464,7 @@ void main() {
...
@@ -455,6 +464,7 @@ void main() {
expect
(
unpadded
.
disableAnimations
,
true
);
expect
(
unpadded
.
disableAnimations
,
true
);
expect
(
unpadded
.
boldText
,
true
);
expect
(
unpadded
.
boldText
,
true
);
expect
(
unpadded
.
highContrast
,
true
);
expect
(
unpadded
.
highContrast
,
true
);
expect
(
unpadded
.
navigationMode
,
NavigationMode
.
directional
);
expect
(
unpadded
.
displayFeatures
,
displayFeatures
);
expect
(
unpadded
.
displayFeatures
,
displayFeatures
);
});
});
...
@@ -489,6 +499,7 @@ void main() {
...
@@ -489,6 +499,7 @@ void main() {
disableAnimations:
true
,
disableAnimations:
true
,
boldText:
true
,
boldText:
true
,
highContrast:
true
,
highContrast:
true
,
navigationMode:
NavigationMode
.
directional
,
displayFeatures:
displayFeatures
,
displayFeatures:
displayFeatures
,
),
),
child:
Builder
(
child:
Builder
(
...
@@ -523,6 +534,7 @@ void main() {
...
@@ -523,6 +534,7 @@ void main() {
expect
(
unpadded
.
disableAnimations
,
true
);
expect
(
unpadded
.
disableAnimations
,
true
);
expect
(
unpadded
.
boldText
,
true
);
expect
(
unpadded
.
boldText
,
true
);
expect
(
unpadded
.
highContrast
,
true
);
expect
(
unpadded
.
highContrast
,
true
);
expect
(
unpadded
.
navigationMode
,
NavigationMode
.
directional
);
expect
(
unpadded
.
displayFeatures
,
displayFeatures
);
expect
(
unpadded
.
displayFeatures
,
displayFeatures
);
});
});
...
@@ -557,6 +569,7 @@ void main() {
...
@@ -557,6 +569,7 @@ void main() {
disableAnimations:
true
,
disableAnimations:
true
,
boldText:
true
,
boldText:
true
,
highContrast:
true
,
highContrast:
true
,
navigationMode:
NavigationMode
.
directional
,
displayFeatures:
displayFeatures
,
displayFeatures:
displayFeatures
,
),
),
child:
Builder
(
child:
Builder
(
...
@@ -588,6 +601,7 @@ void main() {
...
@@ -588,6 +601,7 @@ void main() {
expect
(
unpadded
.
disableAnimations
,
true
);
expect
(
unpadded
.
disableAnimations
,
true
);
expect
(
unpadded
.
boldText
,
true
);
expect
(
unpadded
.
boldText
,
true
);
expect
(
unpadded
.
highContrast
,
true
);
expect
(
unpadded
.
highContrast
,
true
);
expect
(
unpadded
.
navigationMode
,
NavigationMode
.
directional
);
expect
(
unpadded
.
displayFeatures
,
displayFeatures
);
expect
(
unpadded
.
displayFeatures
,
displayFeatures
);
});
});
...
@@ -900,7 +914,7 @@ void main() {
...
@@ -900,7 +914,7 @@ void main() {
);
);
expect
(
expect
(
subScreenMediaQuery
.
viewPadding
,
subScreenMediaQuery
.
viewPadding
,
const
EdgeInsets
.
only
(
top:
6.0
,
left:
4.0
,
right:
8.0
,
bottom:
12.0
),
const
EdgeInsets
.
only
(
top:
6.0
,
left:
4.0
,
right:
8.0
,
bottom:
12.0
),
);
);
expect
(
expect
(
subScreenMediaQuery
.
viewInsets
,
subScreenMediaQuery
.
viewInsets
,
...
...
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