May 16, 2021
Because we can’t call setState() directly in the initState method, we can’t call it from a function called by initState either. Unless this function is asynchronous and the setState call is made after the first await.
The general rule I want to point at here is that setState cannot be called within a synchronous path while the widget is building.