Я сделал бесконечную прокрутку, но я хочу добавить CircularProgressIndicator, пока он загружает элементы списка, я не смог этого сделать. так как я могу добавить CircularProgressIndicator на основе кода вниз:
ListView.builder(
padding: EdgeInsets.symmetric(
vertical: 10, horizontal: 10),
scrollDirection: Axis.vertical,
shrinkWrap: true,
primary: false,
itemCount: _con.brandComplaints.length,
itemBuilder: (context, index) {
if (_con.isLoadingComplaints == false) {
return Padding(
padding: const EdgeInsets.only(
bottom: 15.0),
child: ComplaintItemWidget(
complaint: _con.brandComplaints
.elementAt(index),
),
);
} else {
return Center(
child: CircularProgressIndicator());
}
},
),
---------------------------- Прокрутка Слушатель для прокрутки пунктов списка ----------------------------------
_scrollListener() {
if (int.parse(_con.brand.complaintTotal) == _con.brandComplaints.length) {
return;
}
//print(_scrollController.position.extentAfter);
if (_scrollController.position.extentAfter <= 0 && isPageLoading ==false) {
_con.listenForBrandComplaints(_con.brand.id);
}
}
- ------------------------- Контроллер ------------------------ -------
void listenForBrandComplaints(String idBrand) async {
//setState(() => isLoadingComplaints = true);
final Stream<Complaint> stream =
await getBrandComplaints(idBrand, brandComplaints.length);
stream.listen((Complaint _complaint) {
setState(() => brandComplaints.add(_complaint));
}, onError: (a) {
//setState(() => isLoadingComplaints = false);
print(a);
}, onDone: () {
//setState(() => isLoadingComplaints = false);
//complaintOffset += brandComplaints.length;
});
}