我有以下代码。 newList
包含从snapshot
获取的数据。
Widget _buildListChild(AsyncSnapshot<ModelHolidays> snapshot) {
var data = snapshot.data.d;
newList = json.decode(data.getholidaylist);
return ListView.builder(
padding: EdgeInsets.only(top: size.getSizePx(10)),
scrollDirection: Axis.vertical,
shrinkWrap: true,
physics: const BouncingScrollPhysics(),
itemCount: newList.length,
controller: scrollContainer,
itemBuilder: (context, index) {
final int count = 1;
final Animation<double> animation =
Tween<double>(begin: -1.0, end: 1.0).animate(
CurvedAnimation(
parent: holidayAnimationController,
curve: Interval((1 / count) * index * 2, 1.0,
curve: Curves.fastOutSlowIn),
),
);
holidayAnimationController.forward();
return AnimatedBuilder(
animation: holidayAnimationController,
builder: (BuildContext context, Widget child) {
print("######################");
print("Animated Builder");
print("######################");
return Container();
},
);
});
}
问题
newList
仅从API返回一条记录。但是AnimatedBuilder
似乎有问题。 builder
的{{1}}内的打印语句实际上被打印了70多次。这正常吗?如果没有,怎么解决呢?我在颤抖方面还很陌生。
谢谢