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
01b7ada7
Unverified
Commit
01b7ada7
authored
Feb 23, 2021
by
Nathan Walker
Committed by
GitHub
Feb 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SliverAppBar Default Elevation Patch (#73526)
parent
17c5c4c3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
10 deletions
+59
-10
app_bar.dart
packages/flutter/lib/src/material/app_bar.dart
+1
-1
app_bar_test.dart
packages/flutter/test/material/app_bar_test.dart
+58
-9
No files found.
packages/flutter/lib/src/material/app_bar.dart
View file @
01b7ada7
...
...
@@ -1154,7 +1154,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
?
Semantics
(
child:
flexibleSpace
,
header:
true
)
:
flexibleSpace
,
bottom:
bottom
,
elevation:
forceElevated
||
overlapsContent
||
(
pinned
&&
shrinkOffset
>
maxExtent
-
minExtent
)
?
elevation
??
4.0
:
0.0
,
elevation:
forceElevated
||
overlapsContent
||
(
pinned
&&
shrinkOffset
>
maxExtent
-
minExtent
)
?
elevation
:
0.0
,
shadowColor:
shadowColor
,
backgroundColor:
backgroundColor
,
foregroundColor:
foregroundColor
,
...
...
packages/flutter/test/material/app_bar_test.dart
View file @
01b7ada7
...
...
@@ -903,30 +903,79 @@ void main() {
expect
(
tabBarHeight
(
tester
),
initialTabBarHeight
);
});
testWidgets
(
'SliverAppBar rebuilds when forceElevated changes'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/59158.
Widget
buildSliverAppBar
(
bool
forceElevated
)
{
testWidgets
(
'AppBar uses the specified elevation or defaults to 4.0'
,
(
WidgetTester
tester
)
async
{
Widget
buildAppBar
([
double
?
elevation
])
{
return
MaterialApp
(
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'Title'
),
elevation:
elevation
),
),
);
}
Material
getMaterial
()
=>
tester
.
widget
<
Material
>(
find
.
descendant
(
of:
find
.
byType
(
AppBar
),
matching:
find
.
byType
(
Material
),
));
// Default elevation should be _AppBarState._defaultElevation = 4.0
await
tester
.
pumpWidget
(
buildAppBar
());
expect
(
getMaterial
().
elevation
,
4.0
);
// AppBar should use the specified elevation.
await
tester
.
pumpWidget
(
buildAppBar
(
8.0
));
expect
(
getMaterial
().
elevation
,
8.0
);
});
group
(
'SliverAppBar elevation'
,
()
{
Widget
buildSliverAppBar
(
bool
forceElevated
,
{
double
?
elevation
,
double
?
themeElevation
})
{
return
MaterialApp
(
theme:
ThemeData
(
appBarTheme:
AppBarTheme
(
elevation:
themeElevation
)),
home:
CustomScrollView
(
slivers:
<
Widget
>[
SliverAppBar
(
backwardsCompatibility:
false
,
title:
const
Text
(
'Title'
),
forceElevated:
forceElevated
,
elevation:
elevation
,
),
],
),
);
}
final
Finder
appBarFinder
=
find
.
byType
(
AppBar
);
AppBar
getAppBarWidget
(
Finder
finder
)
=>
tester
.
widget
<
AppBar
>(
finder
);
testWidgets
(
'Respects forceElevated parameter'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/59158.
AppBar
getAppBar
()
=>
tester
.
widget
<
AppBar
>(
find
.
byType
(
AppBar
));
Material
getMaterial
()
=>
tester
.
widget
<
Material
>(
find
.
byType
(
Material
));
// When forceElevated is off, SliverAppBar should not be elevated.
await
tester
.
pumpWidget
(
buildSliverAppBar
(
false
));
expect
(
getMaterial
().
elevation
,
0.0
);
// Default elevation should be _AppBarState._defaultElevation = 4.0, and
// the AppBar's elevation should not be specified by SliverAppBar.
await
tester
.
pumpWidget
(
buildSliverAppBar
(
true
));
expect
(
getMaterial
().
elevation
,
4.0
);
expect
(
getAppBar
().
elevation
,
null
);
await
tester
.
pumpWidget
(
buildSliverAppBar
(
false
));
expect
(
getAppBarWidget
(
appBarFinder
).
elevation
,
0.0
);
// SliverAppBar should use the specified elevation.
await
tester
.
pumpWidget
(
buildSliverAppBar
(
true
,
elevation:
8.0
));
expect
(
getMaterial
().
elevation
,
8.0
);
});
testWidgets
(
'Uses elevation of AppBarTheme by default'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/73525.
Material
getMaterial
()
=>
tester
.
widget
<
Material
>(
find
.
byType
(
Material
));
await
tester
.
pumpWidget
(
buildSliverAppBar
(
false
,
themeElevation:
12.0
));
expect
(
getMaterial
().
elevation
,
0.0
);
await
tester
.
pumpWidget
(
buildSliverAppBar
(
true
));
expect
(
getAppBarWidget
(
appBarFinder
).
elevation
,
4.0
);
await
tester
.
pumpWidget
(
buildSliverAppBar
(
true
,
themeElevation:
12.0
));
expect
(
getMaterial
().
elevation
,
12.0
);
await
tester
.
pumpWidget
(
buildSliverAppBar
(
true
,
elevation:
8.0
,
themeElevation:
12.0
));
expect
(
getMaterial
().
elevation
,
8.0
);
});
});
testWidgets
(
'AppBar dimensions, with and without bottom, primary'
,
(
WidgetTester
tester
)
async
{
...
...
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