Last active
July 11, 2020 17:39
-
-
Save md-weber/5e1cdba4e5c431042a94d37e114aec1e 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
Future getPosts(BuildContext context) async { | |
int index = getFromSF(); | |
QuerySnapshot querySnapshot = | |
await Firestore.instance.collection('fortunepool').getDocuments(); | |
if (indexList.contains(index)) { | |
// TODO: get any other document | |
int currentIndex = index; | |
String myFortune = ""; | |
// This should return you the next title | |
while(index < querySnapshot.documentChanges.length && indexList.contains(currentIndex)){ | |
myFortune = querySnapshot.documents[index++].data['title']; | |
currentIndex = index++; | |
} | |
myFortune = querySnapshot.documents[index++].data['title']; | |
currentIndex = index++; | |
} | |
saveDocumentInSharedPreferences(myFortune); | |
setIndexToSharedFortune(index); | |
indexList.add(index); | |
saveIndexNumbers(indexList, "listofIndexes"); | |
} else if (indexList.isEmpty || index == 5) { | |
// Keep this part if is working | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment