phil
phil

Reputation: 535

Animate height change from the top edge of a widget?

I want to change the height of a widget by moving the top edge (with the bottom, left, and right edges staying fixed). However I haven't been able to do this; I tried SizeTransition, AnimatedPositioned, AnimatedSize, and many combinations thereof, but every time the bottom edge seems to move instead of the top. I'd imagine there's some way to do this, seeing as how in Android and iOS layout constraints make these things fairly trivial. Has anyone been able to implement this?

Upvotes: 0

Views: 217

Answers (1)

phil
phil

Reputation: 535

Found the answer to this. Wrapping AnimatedContainer in a Positioned element worked, here's the code:

Positioned(
  bottom: 0,
  child: AnimatedContainer(
    duration: Duration(milliseconds: 500),
    height: cardHeight, // Varies
    child: Stack(
      children: _buildContent(),
    ),
  ),
),

Upvotes: 1

Related Questions