Created
January 27, 2021 18:33
-
-
Save alphamikle/399ce8fb27f241395e65f218e6b9df1c to your computer and use it in GitHub Desktop.
Loading items in main thread
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<void> loadItemsOnMainThread() async { | |
_startFpsMeter(); | |
isLoading = true; | |
notifyListeners(); | |
List<Item> mainThreadItems; | |
for (int i = 0; i < 10; i++) { | |
bench.startTimer('Load items in main thread'); | |
mainThreadItems = await makeManyRequests(5); | |
final double diff = bench.endTimer('Load items in main thread'); | |
requestDurations.add(diff); | |
} | |
items.clear(); | |
items.addAll(mainThreadItems); | |
isLoading = false; | |
notifyListeners(); | |
_stopFpsMeter(); | |
requestDurations.clear(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment