Flutter - setState not updating inner Stateful Widget

后端 未结 5 463
生来不讨喜
生来不讨喜 2021-02-01 02:57

Basically I am trying to make an app whose content will be updated with an async function that takes information from a website, but when I do try to set the new state, it doesn

5条回答
  •  不思量自难忘°
    2021-02-01 03:06

    I'm unsure why this happens when calling setState(...) in an async function, but one simple solution is to use:

    WidgetsBinding.instance.addPostFrameCallback((_) => setState(...));
    

    instead of just setState(...)

提交回复
热议问题