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
afaedbf2
Commit
afaedbf2
authored
Nov 13, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #375 from abarth/nest_scaffolds
You should be able to nest Scaffolds
parents
56a81089
fc2e31b8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
15 deletions
+41
-15
custom_layout.dart
packages/flutter/lib/src/rendering/custom_layout.dart
+14
-9
custom_multi_child_layout_test.dart
...ages/unit/test/widget/custom_multi_child_layout_test.dart
+27
-6
No files found.
packages/flutter/lib/src/rendering/custom_layout.dart
View file @
afaedbf2
...
...
@@ -10,7 +10,7 @@ class MultiChildLayoutParentData extends ContainerBoxParentDataMixin<RenderBox>
}
abstract
class
MultiChildLayoutDelegate
{
final
Map
<
Object
,
RenderBox
>
_idToChild
=
new
Map
<
Object
,
RenderBox
>()
;
Map
<
Object
,
RenderBox
>
_idToChild
;
/// Returns the size of this object given the incomming constraints.
/// The size cannot reflect the instrinsic sizes of the children.
...
...
@@ -39,15 +39,20 @@ abstract class MultiChildLayoutDelegate {
}
void
_callPerformLayout
(
Size
size
,
BoxConstraints
constraints
,
RenderBox
firstChild
)
{
RenderBox
child
=
firstChild
;
while
(
child
!=
null
)
{
final
MultiChildLayoutParentData
childParentData
=
child
.
parentData
;
assert
(
childParentData
.
id
!=
null
);
_idToChild
[
childParentData
.
id
]
=
child
;
child
=
childParentData
.
nextSibling
;
final
Map
<
Object
,
RenderBox
>
previousIdToChild
=
_idToChild
;
try
{
_idToChild
=
new
Map
<
Object
,
RenderBox
>();
RenderBox
child
=
firstChild
;
while
(
child
!=
null
)
{
final
MultiChildLayoutParentData
childParentData
=
child
.
parentData
;
assert
(
childParentData
.
id
!=
null
);
_idToChild
[
childParentData
.
id
]
=
child
;
child
=
childParentData
.
nextSibling
;
}
performLayout
(
size
,
constraints
);
}
finally
{
_idToChild
=
previousIdToChild
;
}
performLayout
(
size
,
constraints
);
_idToChild
.
clear
();
}
/// Layout and position all children given this widget's size and the specified
...
...
packages/unit/test/widget/custom_multi_child_layout_test.dart
View file @
afaedbf2
...
...
@@ -19,11 +19,13 @@ class TestMultiChildLayoutDelegate extends MultiChildLayoutDelegate {
bool
performLayoutIsChild
;
void
performLayout
(
Size
size
,
BoxConstraints
constraints
)
{
performLayoutSize
=
size
;
performLayoutConstraints
=
constraints
;
performLayoutSize0
=
layoutChild
(
0
,
constraints
);
performLayoutSize1
=
layoutChild
(
1
,
constraints
);
performLayoutIsChild
=
isChild
(
'fred'
);
expect
(()
{
performLayoutSize
=
size
;
performLayoutConstraints
=
constraints
;
performLayoutSize0
=
layoutChild
(
0
,
constraints
);
performLayoutSize1
=
layoutChild
(
1
,
constraints
);
performLayoutIsChild
=
isChild
(
'fred'
);
},
returnsNormally
);
}
}
...
...
@@ -34,7 +36,7 @@ void main() {
tester
.
pumpWidget
(
new
Center
(
child:
new
CustomMultiChildLayout
([
new
LayoutId
(
id:
0
,
child:
new
Container
(
width:
150.0
,
height:
100.0
)),
new
LayoutId
(
id:
1
,
child:
new
Container
(
width:
100.0
,
height:
200.0
))
new
LayoutId
(
id:
1
,
child:
new
Container
(
width:
100.0
,
height:
200.0
))
,
],
delegate:
delegate
)
...
...
@@ -58,4 +60,23 @@ void main() {
expect
(
delegate
.
performLayoutIsChild
,
false
);
});
});
test
(
'Nested CustomMultiChildLayouts'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
TestMultiChildLayoutDelegate
delegate
=
new
TestMultiChildLayoutDelegate
();
tester
.
pumpWidget
(
new
Center
(
child:
new
CustomMultiChildLayout
([
new
LayoutId
(
id:
0
,
child:
new
CustomMultiChildLayout
([
new
LayoutId
(
id:
0
,
child:
new
Container
(
width:
150.0
,
height:
100.0
)),
new
LayoutId
(
id:
1
,
child:
new
Container
(
width:
100.0
,
height:
200.0
)),
],
delegate:
delegate
)
),
new
LayoutId
(
id:
1
,
child:
new
Container
(
width:
100.0
,
height:
200.0
)),
],
delegate:
delegate
)
));
});
});
}
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