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
04e02059
Commit
04e02059
authored
Mar 29, 2016
by
Hans Muller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use _ScaffoldLayout to position scrollable appbars
parent
f4603f76
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
21 deletions
+18
-21
home.dart
examples/material_gallery/lib/gallery/home.dart
+5
-4
scaffold.dart
packages/flutter/lib/src/material/scaffold.dart
+13
-17
No files found.
examples/material_gallery/lib/gallery/home.dart
View file @
04e02059
...
...
@@ -50,13 +50,15 @@ class GalleryHome extends StatefulWidget {
}
class
GalleryHomeState
extends
State
<
GalleryHome
>
{
final
Key
_scrollableKey
=
new
UniqueKey
();
final
Key
_homeKey
=
new
ValueKey
<
String
>(
"Gallery Home"
);
final
Key
_listKey
=
new
ValueKey
<
String
>(
"Gallery List"
);
@override
Widget
build
(
BuildContext
context
)
{
final
double
statusBarHight
=
(
MediaQuery
.
of
(
context
)?.
padding
??
EdgeInsets
.
zero
).
top
;
return
new
Scaffold
(
key:
_homeKey
,
drawer:
new
GalleryDrawer
(),
appBar:
new
AppBar
(
expandedHeight:
_kFlexibleSpaceMaxHeight
,
...
...
@@ -65,13 +67,12 @@ class GalleryHomeState extends State<GalleryHome> {
title:
new
Text
(
"Flutter Gallery"
)
)
),
scrollableKey:
_
scrollable
Key
,
scrollableKey:
_
list
Key
,
appBarBehavior:
AppBarBehavior
.
under
,
body:
new
TwoLevelList
(
scrollablePadding:
new
EdgeInsets
.
only
(
top:
_kFlexibleSpaceMaxHeight
+
statusBarHight
),
key:
_scrollableKey
,
type:
MaterialListType
.
oneLine
,
scrollableKey:
_
scrollable
Key
,
scrollableKey:
_
list
Key
,
items:
<
Widget
>[
new
TwoLevelSublist
(
leading:
new
Icon
(
icon:
Icons
.
star
),
...
...
packages/flutter/lib/src/material/scaffold.dart
View file @
04e02059
...
...
@@ -50,9 +50,10 @@ enum _ScaffoldSlot {
}
class
_ScaffoldLayout
extends
MultiChildLayoutDelegate
{
_ScaffoldLayout
({
this
.
padding
});
_ScaffoldLayout
({
this
.
padding
,
this
.
appBarBehavior
:
AppBarBehavior
.
anchor
});
final
EdgeInsets
padding
;
final
AppBarBehavior
appBarBehavior
;
@override
void
performLayout
(
Size
size
)
{
...
...
@@ -68,7 +69,9 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate {
double
contentBottom
=
size
.
height
-
padding
.
bottom
;
if
(
hasChild
(
_ScaffoldSlot
.
appBar
))
{
contentTop
=
layoutChild
(
_ScaffoldSlot
.
appBar
,
fullWidthConstraints
).
height
;
final
double
appBarHeight
=
layoutChild
(
_ScaffoldSlot
.
appBar
,
fullWidthConstraints
).
height
;
if
(
appBarBehavior
==
AppBarBehavior
.
anchor
)
contentTop
=
appBarHeight
;
positionChild
(
_ScaffoldSlot
.
appBar
,
Offset
.
zero
);
}
...
...
@@ -522,6 +525,8 @@ class ScaffoldState extends State<Scaffold> {
constraints:
new
BoxConstraints
(
maxHeight:
expandedHeight
)
);
_addIfNonNull
(
children
,
appBar
,
_ScaffoldSlot
.
appBar
);
}
else
{
children
.
add
(
new
LayoutId
(
child:
_buildScrollableAppBar
(
context
),
id:
_ScaffoldSlot
.
appBar
));
}
// Otherwise the AppBar will be part of a [app bar, body] Stack. See AppBarBehavior.scroll below.
...
...
@@ -565,21 +570,12 @@ class ScaffoldState extends State<Scaffold> {
if
(
config
.
appBarBehavior
!=
AppBarBehavior
.
anchor
)
{
application
=
new
NotificationListener
<
ScrollNotification
>(
onNotification:
_handleScrollNotification
,
child:
new
Stack
(
children:
<
Widget
>
[
new
CustomMultiChildLayout
(
children:
children
,
delegate:
new
_ScaffoldLayout
(
padding:
EdgeInsets
.
zero
)
),
new
Positioned
(
top:
0.0
,
left:
0.0
,
right:
0.0
,
child:
_buildScrollableAppBar
(
context
)
)
]
child:
new
CustomMultiChildLayout
(
children:
children
,
delegate:
new
_ScaffoldLayout
(
padding:
EdgeInsets
.
zero
,
appBarBehavior:
config
.
appBarBehavior
)
)
);
}
else
{
...
...
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