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,
          width: indicatorWidth,
          margin: EdgeInsets.only(top: indicatorTopMargin),
          color: kGridTextColor,
        ),
        duration: Duration(milliseconds: 200),
      );
posted @ 2019-10-23 18:42  qqcc1388  阅读(1581)  评论(0编辑  收藏  举报