Flutter timing problems on stateful widget after API call. You should use await when invoking your async methods. You can mark initState as async, it will still override.
Make sure to call setState() whenever you mutate member variables.
Check if (mounted) before setState if you are doing it after an async wait, because the widget may no longer be visible.
Consider using FutureBuilder instead of setState when doing async programming.
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.