📱 Flutter
Beginner
What is setState() in Flutter?
Answer
setState() is a method on the State class of a StatefulWidget that notifies the Flutter framework that the internal state has changed and the widget needs to be rebuilt. You pass a callback to setState() that contains the actual state mutation. Flutter schedules a rebuild, calling build() again to generate an updated widget tree. Calling setState() outside of an active State (e.g., after dispose) will throw an error, so always check mounted if the widget might have been removed.
Previous
What is the GridView widget and how does it differ from ListView?
Next
What is the SizedBox widget?