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
b83187d8
Commit
b83187d8
authored
Dec 04, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MultiChildLayoutDelegate should assert that all children have had layoutChild called exactly once
Fixes #692 Fixes #690
parent
eaab8fa1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
custom_layout.dart
packages/flutter/lib/src/rendering/custom_layout.dart
+25
-0
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+3
-1
No files found.
packages/flutter/lib/src/rendering/custom_layout.dart
View file @
b83187d8
...
...
@@ -11,6 +11,7 @@ class MultiChildLayoutParentData extends ContainerBoxParentDataMixin<RenderBox>
abstract
class
MultiChildLayoutDelegate
{
Map
<
Object
,
RenderBox
>
_idToChild
;
Set
<
RenderBox
>
_debugChildrenNeedingLayout
;
/// Returns the size of this object given the incomming constraints.
/// The size cannot reflect the instrinsic sizes of the children.
...
...
@@ -26,6 +27,10 @@ abstract class MultiChildLayoutDelegate {
Size
layoutChild
(
Object
childId
,
BoxConstraints
constraints
)
{
final
RenderBox
child
=
_idToChild
[
childId
];
assert
(
child
!=
null
);
assert
(()
{
'A MultiChildLayoutDelegate cannot layout the same child more than once.'
;
return
_debugChildrenNeedingLayout
.
remove
(
child
);
});
child
.
layout
(
constraints
,
parentUsesSize:
true
);
return
child
.
size
;
}
...
...
@@ -40,6 +45,14 @@ abstract class MultiChildLayoutDelegate {
void
_callPerformLayout
(
Size
size
,
BoxConstraints
constraints
,
RenderBox
firstChild
)
{
final
Map
<
Object
,
RenderBox
>
previousIdToChild
=
_idToChild
;
Set
<
RenderBox
>
debugPreviousChildrenNeedingLayout
;
assert
(()
{
debugPreviousChildrenNeedingLayout
=
_debugChildrenNeedingLayout
;
_debugChildrenNeedingLayout
=
new
Set
<
RenderBox
>();
return
true
;
});
try
{
_idToChild
=
new
Map
<
Object
,
RenderBox
>();
RenderBox
child
=
firstChild
;
...
...
@@ -47,11 +60,23 @@ abstract class MultiChildLayoutDelegate {
final
MultiChildLayoutParentData
childParentData
=
child
.
parentData
;
assert
(
childParentData
.
id
!=
null
);
_idToChild
[
childParentData
.
id
]
=
child
;
assert
(()
{
_debugChildrenNeedingLayout
.
add
(
child
);
return
true
;
});
child
=
childParentData
.
nextSibling
;
}
performLayout
(
size
,
constraints
);
assert
(()
{
'A MultiChildLayoutDelegate needs to call layoutChild on every child.'
;
return
_debugChildrenNeedingLayout
.
isEmpty
;
});
}
finally
{
_idToChild
=
previousIdToChild
;
assert
(()
{
_debugChildrenNeedingLayout
=
debugPreviousChildrenNeedingLayout
;
return
true
;
});
}
}
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
b83187d8
...
...
@@ -305,7 +305,9 @@ class LayoutId extends ParentDataWidget {
Key
key
,
Widget
child
,
this
.
id
})
:
super
(
key:
key
,
child:
child
);
})
:
super
(
key:
key
,
child:
child
)
{
assert
(
child
!=
null
);
}
final
Object
id
;
...
...
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