I have a flip animation on an AnimatedSwitcher between two Card children.
Both Cards contain wrappable text of variable length. So they have different heights - one card might have 1 line of text, the other could have 10. The widths are the same.
When animated as a flipping animation, this looks odd, since it's supposed to be a card flip but the front and back are different heights. It also causes some jank on the flip animation (the height snaps to the taller height when the animation starts).
I would like to fix this by making the shorter Card grow to the same height as the taller Card.
In other words the current flip animation is like this:
------------ ------------------
| Card one | -> | Taller card 2 |
------------ | with more text |
------------------
I would like to change it to:
------------ ------------------
| Card one | -> | Taller card 2 |
| | | with more text |
------------ ------------------
The text can be variable length, so I don't know how to pre-compute a fixed height (maybe there is a way?). And unlike a Row or something, the container only holds 1 card at the start & end of the animation, so I guess there is no easy way to just make the shorter Card "grow" since the taller Card is not even there?
The simplest approach to achieve it is to use IntrinsicHeight
RowwithIntrinsicHeightRow'scrossAxisAlignmentintoCrossAxisAlignment.stretch(for stretching the layout to max row sibling height)This is the example code:
*the code above is runnable in dartpad
And this is the result:
Hopefully it can solve your problem, Thanks