Skip to content

Instantly share code, notes, and snippets.

@alphamikle
Created January 27, 2021 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alphamikle/399ce8fb27f241395e65f218e6b9df1c to your computer and use it in GitHub Desktop.
Save alphamikle/399ce8fb27f241395e65f218e6b9df1c to your computer and use it in GitHub Desktop.
Loading items in main thread
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