rebuild method
Schedules a rebuild of a widget using setState in the next frame.
This ensures rebuilds are deferred until the current frame ends, avoiding conflicts with the Flutter rendering pipeline.
Implementation
void rebuild(void Function(VoidCallback) setState) {
WidgetsBinding.instance.addPostFrameCallback((_) {
setState(() {});
});
}