0

I have an AnimatedPositioned inside bottom stack and I want it to slide into New Parent Stack at the center when I tap on it.

The problem is, bottom Stack's children (the AnimatedPositioned and other sibling AnimatedPositioned widgets) is stream built, so it can change and I dont want it to be lost after it has been slided into the center stack (so I want it to be the child of center stack after it has been placed into center or just tapped).

My solution is (by words, not coded) to remove it from bottom stack, immediately add it into center stack and make its initial position same as its previous position and slide it into the center stack.

So my questions are: Can I change parent of a widget, will it work if I remove same child instance from bottom stack's children and add it into center stack? How can I preserve state (position, size, etc) (just like we do in DOM) Or how can I achive my goal?

enter image description here

Yunus Yurtturk
  • 509
  • 1
  • 8
  • 26
  • cannot you "combine" those two stacks into one big stack? – pskink Nov 08 '21 at 20:04
  • of course but then it makes things so difficult like alignment of widgets – Yunus Yurtturk Nov 09 '21 at 17:24
  • not really, use `Positioned.fromRect` / `AnimatedPositioned.fromRect` where you can precisely align each child – pskink Nov 09 '21 at 17:34
  • Aligning is possible. I dont want to combine all stack children into one big stack, they have different scopes. Some of them are player cards, some of them are cards at table, some of them are ready to be distributed... Things get complex – Yunus Yurtturk Nov 09 '21 at 18:21

0 Answers0