Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

A build is not triggered immediately after calling setState() in Flutter because setState() is an asynchronous method that triggers a rebuild request. The Flutter framework combines multiple rebuild requests that occur within a short amount of time and then schedules a batched rebuild. This is done to improve performance and avoid multiple unnecessary rebuilds.

Additionally, after calling setState(), the framework checks if the state of the widget has actually changed. If there is no change, then a rebuild is not triggered, as this would be unnecessary and inefficient.

Overall, the Flutter framework is designed to optimize the number of rebuilds and reduce the performance overhead of setState() calls.