well except that fetchRecords() is being called multiple times. How can I limit that?
@override
initState() {
List<Map<String, dynamic>> data = [];
bool isLoadingData = false;
_scrollController.addListener(() {
print('condition is ${!isLoadingData && _onScroll(3.0)});
if (!isLoadingData && _onScroll(3.0)) {
if (mounted) {
setState(() {
isLoadingData = true;
fetchRecords (widget.region, subPath);
isLoadingData = false;
});
}
}
});
super.initState();
}
_onScroll checks if the user is 3px away from the bottom of the screen
Обсуждают сегодня