marcglasberg / align_positioned

Flutter Package: When your desired layout or animation is too complex for Columns and Rows, this widget lets you position/size/rotate/transform its child in complex ways.
BSD 2-Clause "Simplified" License
75 stars 8 forks source link

Is it possible with nested stacks? #10

Closed lei-cao closed 2 years ago

lei-cao commented 2 years ago

First of all, thank you for making this library, very easy to use.

The issue I am facing now is that when I try to use AlignPositioned in another stack nested inside the parent AlignPositioned widget, the layout is messed up.

I am wondering if there is any solution for this. Thanks

Stack
 |-- AlignPositioned
       |-- Stack
             |-- AlignPositioned
marcglasberg commented 2 years ago

Yes, of course, it works with nested Stacks, no problem. It's probably just not doing what you think it does.

You are using AlignPositioned to set the size of the inner Stack in relation to the outer Stack. You have to remember a Stack sizes itself in relation to its non-positioned-elements, and then positions the positioned-elements in relation to the Stack size. You are probably messing this up.

I'd suggest you study about Flutter layout, and then re-read Stacks documentation with care. I have written this article that may help with that: https://medium.com/flutter-community/flutter-the-advanced-layout-rule-even-beginners-must-know-edc9516d1a2