我有两个问题,我正在使用页面视图构建器来构建我的日子,
child: PageView.builder(
physics: new AlwaysScrollableScrollPhysics(),
itemCount: allDays.length,
controller: _pageController,
itemBuilder: ( context, int index) {
return _listDay(index);
},
),
每天都包含来自 api 的时间列表,
void initState() {
_futureTime = getDateDayAPI1.getTimeApi(doctorInfoName, widget.dayName);
super.initState();
_futureTime.then((value){
setState(() {
_snapshotTimes.addAll(value);
});
});
_future.then((data) {
setState(() {
_snapshot.addAll(data);
});
},);
}
Widget build(BuildContext context) {
return FutureBuilder(
future: _futureTime,
builder: (context, AsyncSnapshot snapshot){
if (_futureTime == null){
return Container(
child: Center(child: loadingRing(),),
);
}
else {
return SizedBox(
width: 150,
height: 180,
child: ListView.builder(
itemCount: 6,
itemBuilder: (context, index) {
return index == 0 ? Container() : _listItem(index-1);
},
),
);
}
}
);
}
第一个问题是小部件在滚动时自行重建,第二个问题是它在这张图片中显示错误 RangeError (index): Invalid value: Only valid value is 0: 1