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
33777817
Unverified
Commit
33777817
authored
Jun 24, 2020
by
Ayush Bherwani
Committed by
GitHub
Jun 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[AppBar] adds toolbarHeight property to customize AppBar height (#59405)
parent
4d2ddb91
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
24 deletions
+119
-24
app_bar.dart
packages/flutter/lib/src/material/app_bar.dart
+48
-24
app_bar_test.dart
packages/flutter/test/material/app_bar_test.dart
+71
-0
No files found.
packages/flutter/lib/src/material/app_bar.dart
View file @
33777817
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/app_bar_test.dart
View file @
33777817
...
...
@@ -18,6 +18,7 @@ Widget buildSliverAppBarApp({
double
collapsedHeight
,
double
expandedHeight
,
bool
snap
=
false
,
double
toolbarHeight
=
kToolbarHeight
,
})
{
return
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
...
...
@@ -41,6 +42,7 @@ Widget buildSliverAppBarApp({
pinned:
pinned
,
collapsedHeight:
collapsedHeight
,
expandedHeight:
expandedHeight
,
toolbarHeight:
toolbarHeight
,
snap:
snap
,
bottom:
TabBar
(
tabs:
<
String
>[
'A'
,
'B'
,
'C'
].
map
<
Widget
>((
String
t
)
=>
Tab
(
text:
'TAB
$t
'
)).
toList
(),
...
...
@@ -1940,4 +1942,73 @@ void main() {
expect
(
tester
.
getRect
(
appBarTitle
),
const
Rect
.
fromLTRB
(
200
,
-
12
,
800.0
-
200.0
,
68
));
expect
(
tester
.
getCenter
(
appBarTitle
).
dy
,
tester
.
getCenter
(
toolbar
).
dy
);
});
testWidgets
(
'AppBar respects toolbarHeight'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'Title'
),
toolbarHeight:
48
,
),
body:
Container
(),
),
)
);
expect
(
appBarHeight
(
tester
),
48
);
});
testWidgets
(
'SliverAppBar default collapsedHeight with respect to toolbarHeight'
,
(
WidgetTester
tester
)
async
{
const
double
toolbarHeight
=
100.0
;
await
tester
.
pumpWidget
(
buildSliverAppBarApp
(
floating:
false
,
pinned:
false
,
toolbarHeight:
toolbarHeight
,
));
final
ScrollController
controller
=
primaryScrollController
(
tester
);
final
double
initialTabBarHeight
=
tabBarHeight
(
tester
);
// Scroll the not-pinned appbar out of view, to its collapsed height.
controller
.
jumpTo
(
300.0
);
await
tester
.
pump
();
expect
(
find
.
byType
(
SliverAppBar
),
findsNothing
);
// By default, the collapsedHeight is toolbarHeight + bottom.preferredSize.height,
// in this case initialTabBarHeight.
expect
(
appBarHeight
(
tester
),
toolbarHeight
+
initialTabBarHeight
);
});
testWidgets
(
'SliverAppBar collapsedHeight with toolbarHeight'
,
(
WidgetTester
tester
)
async
{
const
double
toolbarHeight
=
100.0
;
const
double
collapsedHeight
=
150.0
;
await
tester
.
pumpWidget
(
buildSliverAppBarApp
(
floating:
false
,
pinned:
false
,
toolbarHeight:
toolbarHeight
,
collapsedHeight:
collapsedHeight
));
final
ScrollController
controller
=
primaryScrollController
(
tester
);
final
double
initialTabBarHeight
=
tabBarHeight
(
tester
);
// Scroll the not-pinned appbar out of view, to its collapsed height.
controller
.
jumpTo
(
300.0
);
await
tester
.
pump
();
expect
(
find
.
byType
(
SliverAppBar
),
findsNothing
);
expect
(
appBarHeight
(
tester
),
collapsedHeight
+
initialTabBarHeight
);
});
test
(
'SliverApp toolbarHeight cannot be null'
,
()
{
try
{
SliverAppBar
(
toolbarHeight:
null
,
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'toolbarHeight != null'
));
expect
(
error
.
toString
(),
contains
(
'is not true'
));
}
});
}
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