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
e12c7516
Unverified
Commit
e12c7516
authored
Jun 09, 2021
by
Rami
Committed by
GitHub
Jun 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only trigger AppBar scrolledUnder state for vertical scrolling and not horizontal (#84268)
parent
ae976665
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
1 deletion
+53
-1
app_bar.dart
packages/flutter/lib/src/material/app_bar.dart
+3
-1
app_bar_test.dart
packages/flutter/test/material/app_bar_test.dart
+50
-0
No files found.
packages/flutter/lib/src/material/app_bar.dart
View file @
e12c7516
...
@@ -762,7 +762,9 @@ class _AppBarState extends State<AppBar> {
...
@@ -762,7 +762,9 @@ class _AppBarState extends State<AppBar> {
void
_handleScrollNotification
(
ScrollNotification
notification
)
{
void
_handleScrollNotification
(
ScrollNotification
notification
)
{
if
(
notification
is
ScrollUpdateNotification
)
{
if
(
notification
is
ScrollUpdateNotification
)
{
final
bool
oldScrolledUnder
=
_scrolledUnder
;
final
bool
oldScrolledUnder
=
_scrolledUnder
;
_scrolledUnder
=
notification
.
depth
==
0
&&
notification
.
metrics
.
extentBefore
>
0
;
_scrolledUnder
=
notification
.
depth
==
0
&&
notification
.
metrics
.
extentBefore
>
0
&&
notification
.
metrics
.
axis
==
Axis
.
vertical
;
if
(
_scrolledUnder
!=
oldScrolledUnder
)
{
if
(
_scrolledUnder
!=
oldScrolledUnder
)
{
setState
(()
{
setState
(()
{
// React to a change in MaterialState.scrolledUnder
// React to a change in MaterialState.scrolledUnder
...
...
packages/flutter/test/material/app_bar_test.dart
View file @
e12c7516
...
@@ -2910,6 +2910,56 @@ void main() {
...
@@ -2910,6 +2910,56 @@ void main() {
expect
(
tester
.
takeException
(),
isNull
);
expect
(
tester
.
takeException
(),
isNull
);
});
});
testWidgets
(
'AppBar scrolledUnder does not trigger on horizontal scroll'
,
(
WidgetTester
tester
)
async
{
const
Color
scrolledColor
=
Color
(
0xff00ff00
);
const
Color
defaultColor
=
Color
(
0xff0000ff
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
appBar:
AppBar
(
backwardsCompatibility:
false
,
elevation:
0
,
backgroundColor:
MaterialStateColor
.
resolveWith
((
Set
<
MaterialState
>
states
)
{
return
states
.
contains
(
MaterialState
.
scrolledUnder
)
?
scrolledColor
:
defaultColor
;
}),
title:
const
Text
(
'AppBar'
),
),
body:
ListView
(
scrollDirection:
Axis
.
horizontal
,
children:
<
Widget
>[
Container
(
height:
600.0
,
width:
1200.0
,
color:
Colors
.
teal
),
],
),
),
),
);
Finder
findAppBarMaterial
()
{
return
find
.
descendant
(
of:
find
.
byType
(
AppBar
),
matching:
find
.
byType
(
Material
));
}
Color
?
getAppBarBackgroundColor
()
{
return
tester
.
widget
<
Material
>(
findAppBarMaterial
()).
color
;
}
expect
(
getAppBarBackgroundColor
(),
defaultColor
);
TestGesture
gesture
=
await
tester
.
startGesture
(
const
Offset
(
50.0
,
400.0
));
await
gesture
.
moveBy
(
const
Offset
(-
100.0
,
0.0
));
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
expect
(
getAppBarBackgroundColor
(),
defaultColor
);
gesture
=
await
tester
.
startGesture
(
const
Offset
(
50.0
,
400.0
));
await
gesture
.
moveBy
(
const
Offset
(
100.0
,
0.0
));
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
expect
(
getAppBarBackgroundColor
(),
defaultColor
);
});
testWidgets
(
'AppBar.preferredHeightFor'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'AppBar.preferredHeightFor'
,
(
WidgetTester
tester
)
async
{
late
double
preferredHeight
;
late
double
preferredHeight
;
late
Size
preferredSize
;
late
Size
preferredSize
;
...
...
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