flutter AnimatedPositioned

Positioned 的动画版。

只有是 Stack 的 child 时才能工作。

如果 child 的 size 在动画过程会改变,则 AnimatedPositioned 是很好的选择

    double indicatorWidth = (width * 2 / 3).ceilToDouble();
    double indicatorHeight = 2;
    double indicatorTopMargin = height - indicatorHeight*2;
    double left = (currentIndex * width + indicatorWidth / 4).ceilToDouble();
  Widget _indicator() {
      return AnimatedPositioned(
        left: left,
        child: Container(
          height: indicatorHeight,
           indicatorWidth,
          margin: EdgeInsets.only(top: indicatorTopMargin),
          color: kGridTextColor,
        ),
        duration: Duration(milliseconds: 200),
      );
原文地址:https://www.cnblogs.com/qqcc1388/p/11728028.html