Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hamza39460/6ab250b0664634e426ad58076a692180 to your computer and use it in GitHub Desktop.
Save hamza39460/6ab250b0664634e426ad58076a692180 to your computer and use it in GitHub Desktop.
class APIManager {
// Self Instance since we are creating a Singleton Class
static final APIManager _shared = APIManager._internal();
// Private Constructor
APIManager._internal();
// Factory Constructor
factory APIManager() {
return _shared;
}
// Dummy Method of fetchData
// This will generate a String list and return that list
Future fetchData(int currentPage) async {
await new Future.delayed(new Duration(seconds: 2));
List<String> _list = [];
int startIndex = currentPage * 10;
for (int i = startIndex; i < startIndex + 10; i++) {
_list.add("Item #$i");
}
return _list;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment