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
67797182
Unverified
Commit
67797182
authored
Feb 28, 2023
by
Kate Lovett
Committed by
GitHub
Feb 28, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix scrolled under for 2D scrolling (#121297)
Fix AppBar scrolled under for 2D scrolling
parent
1bfba756
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
2 deletions
+61
-2
app_bar.dart
packages/flutter/lib/src/material/app_bar.dart
+3
-2
app_bar_test.dart
packages/flutter/test/material/app_bar_test.dart
+58
-0
No files found.
packages/flutter/lib/src/material/app_bar.dart
View file @
67797182
...
...
@@ -768,8 +768,9 @@ class _AppBarState extends State<AppBar> {
break
;
case
AxisDirection
.
right
:
case
AxisDirection
.
left
:
// Scrolled under is only supported in the vertical axis.
_scrolledUnder
=
false
;
// Scrolled under is only supported in the vertical axis, and should
// not be altered based on horizontal notifications of the same
// predicate since it could be a 2D scroller.
break
;
}
...
...
packages/flutter/test/material/app_bar_test.dart
View file @
67797182
...
...
@@ -3598,6 +3598,64 @@ void main() {
);
}
testWidgets
(
'backgroundColor for horizontal scrolling'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
appBar:
AppBar
(
elevation:
0
,
backgroundColor:
MaterialStateColor
.
resolveWith
((
Set
<
MaterialState
>
states
)
{
return
states
.
contains
(
MaterialState
.
scrolledUnder
)
?
scrolledColor
:
defaultColor
;
}),
title:
const
Text
(
'AppBar'
),
notificationPredicate:
(
ScrollNotification
notification
)
{
// Represents both scroll views below being treated as a
// single viewport.
return
notification
.
depth
<=
1
;
},
),
body:
SingleChildScrollView
(
child:
SingleChildScrollView
(
scrollDirection:
Axis
.
horizontal
,
child:
Container
(
height:
1200
,
width:
1200
,
color:
Colors
.
teal
,
),
),
),
),
)
);
expect
(
getAppBarBackgroundColor
(
tester
),
defaultColor
);
expect
(
tester
.
getSize
(
findAppBarMaterial
()).
height
,
kToolbarHeight
);
TestGesture
gesture
=
await
tester
.
startGesture
(
const
Offset
(
50.0
,
400.0
));
await
gesture
.
moveBy
(
const
Offset
(
0.0
,
-
kToolbarHeight
));
await
tester
.
pump
();
await
gesture
.
moveBy
(
const
Offset
(
0.0
,
-
kToolbarHeight
));
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
expect
(
getAppBarBackgroundColor
(
tester
),
scrolledColor
);
expect
(
tester
.
getSize
(
findAppBarMaterial
()).
height
,
kToolbarHeight
);
gesture
=
await
tester
.
startGesture
(
const
Offset
(
50.0
,
300.0
));
// Scroll horizontally
await
gesture
.
moveBy
(
const
Offset
(-
kToolbarHeight
,
0.0
));
await
tester
.
pump
();
await
gesture
.
moveBy
(
const
Offset
(-
kToolbarHeight
,
0.0
));
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
// The app bar is still scrolled under vertically, so it should not have
// changed back in response to horizontal scrolling.
expect
(
getAppBarBackgroundColor
(
tester
),
scrolledColor
);
expect
(
tester
.
getSize
(
findAppBarMaterial
()).
height
,
kToolbarHeight
);
});
testWidgets
(
'backgroundColor'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
buildAppBar
(
contentHeight:
1200.0
)
...
...
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