Итак, в моей функции сборки я загружаю свои пользовательские данные, и после их загрузки я хочу изменить тему приложения (которая вызывает setState ()).Проблема в том, что я не могу вызвать setState во время процесса сборки, как показано в приведенной ниже ошибке.Как бы я мог загрузить выбранную пользователем тему при запуске приложения?Кроме того, не рекомендуется загружать данные внутри функции сборки?Кажется, работает хорошо, но чувствует себя немного брутто.Спасибо!
Widget build(BuildContext context) {
//get user object from Firebase
//once user is loaded, take their chosen color theme and call updateTheme()
}
Ошибка:
This ThemeSwitcherWidget widget cannot be marked as needing to build because the framework is
I/flutter (23889): already in the process of building widgets. A widget can be marked as needing to be built during the
I/flutter (23889): build phase only if one of its ancestors is currently building. This exception is allowed because
I/flutter (23889): the framework builds parent widgets before children, which means a dirty descendant will always be