add fetchcount #44
@ -469,15 +469,17 @@ class _MyHomePageState extends State<ListItemMenu> {
|
|||||||
print("results fetch : ${body}");
|
print("results fetch : ${body}");
|
||||||
print("fetch count : ${_fetchCount}");
|
print("fetch count : ${_fetchCount}");
|
||||||
// Update state after getting the response
|
// Update state after getting the response
|
||||||
if (body.isEmpty) {
|
|
||||||
_fetchCount--;
|
|
||||||
}
|
|
||||||
setState(() {
|
setState(() {
|
||||||
if (body.isNotEmpty) {
|
if (body.isNotEmpty) {
|
||||||
|
int counter = filteredPosts.length;
|
||||||
// If we have results, map them to Events
|
// If we have results, map them to Events
|
||||||
filteredPosts = body
|
filteredPosts = body
|
||||||
.map((e) => Events.fromJson(e as Map<String, dynamic>))
|
.map((e) => Events.fromJson(e as Map<String, dynamic>))
|
||||||
.toList();
|
.toList();
|
||||||
|
if (counter == filteredPosts.length) {
|
||||||
|
_fetchCount--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user