-
-
Save anmolgupta-aeologic/bb35406fedeeb5ba018d3d7fda1e389e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:get/get.dart'; | |
import 'package:getx_pagination/main.dart'; | |
class HomePageController extends GetxController { | |
List<Model> list = []; | |
ScrollController controller = ScrollController(); | |
int listLength = 6; | |
void onInit() { | |
generateList(); | |
addItems(); | |
super.onInit(); | |
} | |
addItems() async { | |
controller.addListener(() { | |
if (controller.position.maxScrollExtent == controller.position.pixels) { | |
for (int i = 0; i < 2; i++) { | |
listLength++; | |
list.add(Model(name: (listLength).toString())); | |
update(); | |
} | |
} | |
}); | |
} | |
generateList() { | |
list = List.generate( | |
listLength, (index) => Model(name: (index + 1).toString())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment