flutter infinite scroll view with getx and http

This post is about the infinite scroll view with getx and http. There are lots of pages regarding the infinite scroll view. But I needed to know how to use the infinite scroll view with getx and http correctly.


The requirements to implement are as below,

  • receives json data through http
  • processes the received json data for getx mode classes
  • shows the data on the scroll view
  • provides pagination by bottom scrolling

Triggering specific callbacks when an event occurs.

/// Called every time `count1` changes.
ever(count1, (_) => print("$_ has been changed"));

/// Called only first time the variable $_ is changed
once(count1, (_) => print("$_ was changed once"));

/// Anti DDos - Called every time the user stops typing for 1 second, for example.
debounce(count1, (_) => print("debouce$_"), time: Duration(seconds: 1));

/// Ignore all changes within 1 second.
interval(count1, (_) => print("interval $_"), time: Duration(seconds: 1));

http query parameters

final queryParameters = {
    'param1': 'one',
    'param2': 'two',
};

final uri =
    Uri.https('www.myurl.com', '/api/v1/test/${widget.pk}', queryParameters);
final response = await http.get(uri, headers: {
    HttpHeaders.authorizationHeader: 'Token $token',
    HttpHeaders.contentTypeHeader: 'application/json',
});

References

Updated: