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
30adac1a
Unverified
Commit
30adac1a
authored
Mar 22, 2018
by
Greg Spencer
Committed by
GitHub
Mar 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updating example for MultiChildLayoutDelegate (#15597)
parent
f2ffc8de
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
18 deletions
+42
-18
custom_layout.dart
packages/flutter/lib/src/rendering/custom_layout.dart
+32
-15
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+4
-1
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+6
-2
No files found.
packages/flutter/lib/src/rendering/custom_layout.dart
View file @
30adac1a
...
...
@@ -41,26 +41,43 @@ class MultiChildLayoutParentData extends ContainerBoxParentData<RenderBox> {
/// Used with [CustomMultiChildLayout], the widget for the
/// [RenderCustomMultiChildLayoutBox] render object.
///
/// ## Example
/// Each child must be wrapped in a [LayoutId] widget to assign the id that
/// identifies it to the delegate. The [LayoutId.id] needs to be unique among
/// the children that the [CustomMultiChildLayout] manages.
///
/// ## Sample code
///
/// Below is an example implementation of [performLayout] that causes one widget
///
to be the same size as another
:
///
(the follower) to be the same size as another (the leader)
:
///
/// ```dart
/// @override
/// void performLayout(Size size) {
/// Size followerSize = Size.zero;
///
/// if (hasChild(_Slots.leader) {
/// followerSize = layoutChild(_Slots.leader, new BoxConstraints.loose(size));
/// positionChild(_Slots.leader, Offset.zero);
/// }
///
/// if (hasChild(_Slots.follower)) {
/// layoutChild(_Slots.follower, new BoxConstraints.tight(followerSize));
/// positionChild(_Slots.follower, new Offset(size.width - followerSize.width,
/// size.height - followerSize.height));
/// // Define your own slot numbers, depending upon the id assigned by LayoutId.
/// // Typical usage is to define an enum like the one below, and use those
/// // values as the ids.
/// enum _Slot {
/// leader,
/// follower,
/// }
///
/// class FollowTheLeader extends MultiChildLayoutDelegate {
/// @override
/// void performLayout(Size size) {
/// Size leaderSize = Size.zero;
///
/// if (hasChild(_Slot.leader)) {
/// leaderSize = layoutChild(_Slot.leader, new BoxConstraints.loose(size));
/// positionChild(_Slot.leader, Offset.zero);
/// }
///
/// if (hasChild(_Slot.follower)) {
/// layoutChild(_Slot.follower, new BoxConstraints.tight(leaderSize));
/// positionChild(_Slot.follower, new Offset(size.width - leaderSize.width,
/// size.height - leaderSize.height));
/// }
/// }
///
/// @override
/// bool shouldRelayout(MultiChildLayoutDelegate oldDelegate) => false;
/// }
/// ```
///
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
30adac1a
...
...
@@ -1448,7 +1448,7 @@ class CustomSingleChildLayout extends SingleChildRenderObjectWidget {
}
}
/// Meta
data for identifying children in a [CustomMultiChildLayout].
/// Metadata for identifying children in a [CustomMultiChildLayout].
///
/// The [MultiChildLayoutDelegate.hasChild],
/// [MultiChildLayoutDelegate.layoutChild], and
...
...
@@ -1466,6 +1466,9 @@ class LayoutId extends ParentDataWidget<CustomMultiChildLayout> {
super
(
key:
key
??
new
ValueKey
<
Object
>(
id
),
child:
child
);
/// An object representing the identity of this child.
///
/// The [id] needs to be unique among the children that the
/// [CustomMultiChildLayout] manages.
final
Object
id
;
@override
...
...
packages/flutter/lib/src/widgets/framework.dart
View file @
30adac1a
...
...
@@ -4462,13 +4462,17 @@ abstract class RenderObjectElement extends Element {
@override
void
deactivate
()
{
super
.
deactivate
();
assert
(!
renderObject
.
attached
);
assert
(!
renderObject
.
attached
,
'A RenderObject was still attached when attempting to deactivate its '
'RenderObjectElement:
$renderObject
'
);
}
@override
void
unmount
()
{
super
.
unmount
();
assert
(!
renderObject
.
attached
);
assert
(!
renderObject
.
attached
,
'A RenderObject was still attached when attempting to unmount its '
'RenderObjectElement:
$renderObject
'
);
widget
.
didUnmountRenderObject
(
renderObject
);
}
...
...
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