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),
);
