add pagination for other pages
This commit is contained in:
parent
afae3293c4
commit
3a64f1ae36
@ -54,23 +54,12 @@ class _MyHomePageState extends State<ListItemOrganizers> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _decrementFetchCount() {
|
|
||||||
setState(() {
|
|
||||||
if (_fetchCount > 0) {
|
|
||||||
_fetchCount--;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _scrollListener() {
|
void _scrollListener() {
|
||||||
if (_scrollController.position.pixels ==
|
if (_scrollController.position.pixels ==
|
||||||
_scrollController.position.maxScrollExtent) {
|
_scrollController.position.maxScrollExtent) {
|
||||||
_incrementFetchCount();
|
_incrementFetchCount();
|
||||||
} else if (_scrollController.position.pixels ==
|
_fetchData();
|
||||||
_scrollController.position.minScrollExtent) {
|
|
||||||
_decrementFetchCount();
|
|
||||||
}
|
}
|
||||||
_fetchData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _fetchData() async {
|
Future<void> _fetchData() async {
|
||||||
@ -97,8 +86,9 @@ class _MyHomePageState extends State<ListItemOrganizers> {
|
|||||||
final List<Events> body = [];
|
final List<Events> body = [];
|
||||||
if (accessToken.isNotEmpty) {
|
if (accessToken.isNotEmpty) {
|
||||||
DateTime currentDatetime = DateTime.now();
|
DateTime currentDatetime = DateTime.now();
|
||||||
|
num limit = 20 * (count + 1);
|
||||||
var url = Uri.parse(
|
var url = Uri.parse(
|
||||||
"${globals.api}/events?organizers=${organizer}&skip=${count}¤t_datetime=${currentDatetime.toString()}");
|
"${globals.api}/events?organizers=${organizer}&limit=${limit}¤t_datetime=${currentDatetime.toString()}");
|
||||||
final response = await http.get(url, headers: {
|
final response = await http.get(url, headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
HttpHeaders.cookieHeader: "access_token=${accessToken}"
|
HttpHeaders.cookieHeader: "access_token=${accessToken}"
|
||||||
|
@ -56,23 +56,13 @@ class _MyHomePageState extends State<ListItemTags> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _decrementFetchCount() {
|
|
||||||
setState(() {
|
|
||||||
if (_fetchCount > 0) {
|
|
||||||
_fetchCount--;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _scrollListener() {
|
void _scrollListener() {
|
||||||
if (_scrollController.position.pixels ==
|
if (_scrollController.position.pixels ==
|
||||||
_scrollController.position.maxScrollExtent) {
|
_scrollController.position.maxScrollExtent) {
|
||||||
_incrementFetchCount();
|
_incrementFetchCount();
|
||||||
} else if (_scrollController.position.pixels ==
|
|
||||||
_scrollController.position.minScrollExtent) {
|
_fetchData();
|
||||||
_decrementFetchCount();
|
|
||||||
}
|
}
|
||||||
_fetchData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _fetchData() async {
|
Future<void> _fetchData() async {
|
||||||
@ -97,8 +87,10 @@ class _MyHomePageState extends State<ListItemTags> {
|
|||||||
final List<Events> body = [];
|
final List<Events> body = [];
|
||||||
if (accessToken.isNotEmpty) {
|
if (accessToken.isNotEmpty) {
|
||||||
DateTime currentDatetime = DateTime.now();
|
DateTime currentDatetime = DateTime.now();
|
||||||
|
num limit = 20 * (count + 1);
|
||||||
|
|
||||||
var url = Uri.parse(
|
var url = Uri.parse(
|
||||||
"${globals.api}/events?tags=${tags}&skip=${count}¤t_datetime=${currentDatetime.toString()}");
|
"${globals.api}/events?tags=${tags}&limit=${limit}¤t_datetime=${currentDatetime.toString()}");
|
||||||
final response = await http.get(url, headers: {
|
final response = await http.get(url, headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
HttpHeaders.cookieHeader: "access_token=${accessToken}"
|
HttpHeaders.cookieHeader: "access_token=${accessToken}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user