Ask Your Question
0

What does the error "setState() or markNeedsBuild() called during build" in a provider class mean for Flutter?

asked 2022-02-11 11:00:00 +0000

huitzilopochtli gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-06-29 00:00:00 +0000

scrum gravatar image

The error "setState() or markNeedsBuild() called during build" in a provider class means that the state of the widget is being changed during the build process, which is not allowed in Flutter. This error typically occurs when there is a change to the data model triggering a state change, but the widget is already in the process of being built. To resolve this error, it's important to ensure that any state changes are made before or after the build process. One way to achieve this is by using a Future or a FutureBuilder to make the state changes once the build process is complete.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-02-11 11:00:00 +0000

Seen: 9 times

Last updated: Jun 29 '21