Created
August 29, 2021 15:51
-
-
Save hamza39460/6ab250b0664634e426ad58076a692180 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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