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
32157e3f
Unverified
Commit
32157e3f
authored
May 18, 2022
by
Taha Tesser
Committed by
GitHub
May 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
`AppBar`: Fix nested scroll view doesn't update `AppBar` elevation for Material 3 (#103899)
parent
64cba0e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
1 deletion
+57
-1
app_bar.dart
packages/flutter/lib/src/material/app_bar.dart
+10
-1
app_bar_test.dart
packages/flutter/test/material/app_bar_test.dart
+47
-0
No files found.
packages/flutter/lib/src/material/app_bar.dart
View file @
32157e3f
...
...
@@ -162,6 +162,7 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
this
.
bottom
,
this
.
elevation
,
this
.
scrolledUnderElevation
,
this
.
notificationPredicate
=
defaultScrollNotificationPredicate
,
this
.
shadowColor
,
this
.
surfaceTintColor
,
this
.
shape
,
...
...
@@ -197,6 +198,7 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
this
.
systemOverlayStyle
,
})
:
assert
(
automaticallyImplyLeading
!=
null
),
assert
(
elevation
==
null
||
elevation
>=
0.0
),
assert
(
notificationPredicate
!=
null
),
assert
(
primary
!=
null
),
assert
(
toolbarOpacity
!=
null
),
assert
(
bottomOpacity
!=
null
),
...
...
@@ -421,6 +423,13 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
/// shadow.
final
double
?
scrolledUnderElevation
;
/// A check that specifies which child's [ScrollNotification]s should be
/// listened to.
///
/// By default, checks whether `notification.depth == 0`. Set it to something
/// else for more complicated layouts.
final
ScrollNotificationPredicate
notificationPredicate
;
/// {@template flutter.material.appbar.shadowColor}
/// The color of the shadow below the app bar.
///
...
...
@@ -809,7 +818,7 @@ class _AppBarState extends State<AppBar> {
}
void
_handleScrollNotification
(
ScrollNotification
notification
)
{
if
(
notification
is
ScrollUpdateNotification
&&
notification
.
depth
==
0
)
{
if
(
notification
is
ScrollUpdateNotification
&&
widget
.
notificationPredicate
(
notification
)
)
{
final
bool
oldScrolledUnder
=
_scrolledUnder
;
final
ScrollMetrics
metrics
=
notification
.
metrics
;
switch
(
metrics
.
axisDirection
)
{
...
...
packages/flutter/test/material/app_bar_test.dart
View file @
32157e3f
...
...
@@ -1011,6 +1011,53 @@ void main() {
expect
(
getMaterial
().
elevation
,
10
);
});
testWidgets
(
'scrolledUnderElevation with nested scroll view'
,
(
WidgetTester
tester
)
async
{
Widget
buildAppBar
({
double
?
scrolledUnderElevation
})
{
return
MaterialApp
(
theme:
ThemeData
(
useMaterial3:
true
),
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'Title'
),
scrolledUnderElevation:
scrolledUnderElevation
,
notificationPredicate:
(
ScrollNotification
notification
)
{
return
notification
.
depth
==
1
;
},
),
body:
ListView
.
builder
(
scrollDirection:
Axis
.
horizontal
,
itemCount:
4
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
SizedBox
(
height:
600.0
,
width:
800.0
,
child:
ListView
.
builder
(
itemCount:
100
,
itemBuilder:
(
BuildContext
context
,
int
index
)
=>
ListTile
(
title:
Text
(
'Item
$index
'
)),
),
);
},
),
),
);
}
Material
getMaterial
()
=>
tester
.
widget
<
Material
>(
find
.
descendant
(
of:
find
.
byType
(
AppBar
),
matching:
find
.
byType
(
Material
),
));
await
tester
.
pumpWidget
(
buildAppBar
(
scrolledUnderElevation:
10
));
// Starts with the base elevation.
expect
(
getMaterial
().
elevation
,
0.0
);
await
tester
.
fling
(
find
.
text
(
'Item 2'
),
const
Offset
(
0.0
,
-
600.0
),
2000.0
);
await
tester
.
pumpAndSettle
();
// After scrolling it should be the scrolledUnderElevation.
expect
(
getMaterial
().
elevation
,
10
);
});
group
(
'SliverAppBar elevation'
,
()
{
Widget
buildSliverAppBar
(
bool
forceElevated
,
{
double
?
elevation
,
double
?
themeElevation
})
{
return
MaterialApp
(
...
...
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