setState() lên lịch rebuild subtree cho frame tiếp theo — chỉ dùng cho state UI cục bộ đơn giản, không dùng cho animation hay stream.
- Nó đánh dấu widget cần rebuild và thông báo cho Flutter framework; thay đổi state bên trong callback được phản ánh trong lần build tiếp theo.
- Không dùng
setState()cho cập nhật liên tục (animation, stream); dùngAnimatedBuilderhoặc state management thay thế.
setState() marks the widget as needing rebuild and notifies the Flutter framework.
- It schedules a rebuild during the next frame, not immediately.
- Never use
setState()for frequent updates like animations; useAnimatedBuilderor state management solutions instead.