Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Stack squishes positioned elements near the edge #714

Merged
merged 1 commit into from
Aug 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/widgets/card_collection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class CardCollectionApp extends App {
// background (text and icons) will just be clipped, not resized.
Widget background = new Positioned(
top: 0.0,
right: 0.0,
bottom: 0.0,
left: 0.0,
child: new Container(
margin: const EdgeDims.all(4.0),
Expand Down
12 changes: 1 addition & 11 deletions sky/packages/sky/lib/rendering/stack.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,29 +146,19 @@ class RenderStack extends RenderBox with ContainerRenderObjectMixin<RenderBox, S
assert(size.width == constraints.constrainWidth(width));
assert(size.height == constraints.constrainHeight(height));

BoxConstraints innerConstraints = new BoxConstraints.loose(size);

child = firstChild;
while (child != null) {
assert(child.parentData is StackParentData);
final StackParentData childData = child.parentData;

if (childData.isPositioned) {
BoxConstraints childConstraints = innerConstraints;
BoxConstraints childConstraints = const BoxConstraints();

if (childData.left != null && childData.right != null)
childConstraints = childConstraints.applyWidth(size.width - childData.right - childData.left);
else if (childData.left != null)
childConstraints = childConstraints.applyMaxWidth(size.width - childData.left);
else if (childData.right != null)
childConstraints = childConstraints.applyMaxWidth(size.width - childData.right);

if (childData.top != null && childData.bottom != null)
childConstraints = childConstraints.applyHeight(size.height - childData.bottom - childData.top);
else if (childData.top != null)
childConstraints = childConstraints.applyMaxHeight(size.height - childData.top);
else if (childData.bottom != null)
childConstraints = childConstraints.applyMaxHeight(size.width - childData.bottom);

child.layout(childConstraints, parentUsesSize: true);

Expand Down