Container height Animation starts from the middle Container height Animation starts from the middle dart dart

Container height Animation starts from the middle


to start scale animation from certain points. You can wrap your Container with Align widget and give certain start positions with simplicty.

define your controller and animation variables;

  AnimationController animationController;  Animation<double> tween;

init them in initState method;

   @override  void initState() {     super.initState();     animationController = AnimationController(vsync: this, duration: Duration(milliseconds: 800));     tween = Tween<double>(begin:0,end:1).animate(CurvedAnimation(parent: animationController, curve: Curves.easeIn));     animationController.addListener(() {       setState(() {});     });}

then in build method or where ever you add use return Widget like below;

Widget animatedContainer(){  return Align(    alignment: Alignment.topRight,// .topCenter, .topLeft, .bottomLeft, bottomCenter...etc    child: Container(      width: (size.width * tween.value).abs(),      height: (200 *tween.value).abs(),      color:Colors.red      ),  );}