The short answer is that just add currentIndex as one of the parameter inside your navBarSection . Inside home. dart , just pass the currentIndex of the page.
Read moreWhy do you need to call setState in a stateful widget?
Calling setState notifies the framework that the internal state of this object has changed in a way that might impact the user interface in this subtree , which causes the framework to schedule a build for this State object.
Read moreWhich method is called to Rerender the widget tree once state is changed?
The setState() method notifies the framework that the internal state of the current object is “dirty,” which means that it has been changed in a way that might impact the UI. After this notification, the framework will call the build() method to update and rebuild a widget.
Read moreWhy do you need to call setState (() }) in a stateful widget when changing some internal data )?
setState is a way to dynamically change the UI. We call it inside the State Object class of the StatefulWidget. Calling setState marks the corresponding Widget dirty .20 Haz 2021
Read moreHow do I make widgets not rebuild in flutter?
The ultimate solution to prevent widget rebuild by flutter
Read moreHow do I rebuild a child’s widget?
A nice way to rebuild only a child widget when a value in the parent changes is to use ValueNotifier and ValueListenableBuilder . Add an instance of ValueNotifier to the parent’s state class, and wrap the widget you want to rebuild in a ValueListenableBuilder .
Read moreDoes setState rebuild widget?
When setState() is called on a State, all descendent widgets rebuild . Therefore, localize the setState() call to the part of the subtree whose UI actually needs to change.
Read more