use-setstate-synchronously (Rules of the Week)

preview_player
Показать описание
"use-setstate-synchronously" warns when "setState" is called past an await point (also known as asynchronous gap) within a subclass of "State".

In async functions, the state of a widget may have been disposed between await points, e.g. because the user moved to another screen, leading to errors calling "setState". After each await point, i.e. when a Future is awaited, the possibility that the widget has been unmounted needs to be checked before calling "setState".

To fix that, check for "mounted" to only update state when the widget is still mounted. However, an effective fix usually does not make use of "mounted", but rather revolves around refactoring your states.

#Flutter #RulesOfTheWeek
Рекомендации по теме
join shbcf.ru