- override
Called whenever the configuration changes.
If the parent widget rebuilds and request that this location in the tree
update to display a new widget with the same runtimeType
and key
, the
framework will update the config
property of this State
object to
refer to the new widget and then call the this method with the previous
widget as an argument.
Override this method to respond to changes in the config
widget (e.g.,
to start implicit animations).
The framework always calls build
after calling didUpdateConfig
, which
means any calls to setState
in didUpdateConfig
are redundant.
If a State
's build
method depends on an object that can itself change
state, for example a ChangeNotifier
or Stream
, or some other object to
which one can subscribe to receive notifications, then the State
should
subscribe to that object during initState
, unsubscribe from the old
object and subscribe to the new object when it changes in
didUpdateConfig
, and then unsubscribe from the object in dispose
.
If you override this, make sure your method starts with a call to super.didUpdateConfig(oldConfig).
Source
@override void didUpdateConfig(BottomNavigationBar oldConfig) { if (config.currentIndex != oldConfig.currentIndex) { if (config.type == BottomNavigationBarType.shifting) _pushCircle(config.currentIndex); _controllers[oldConfig.currentIndex].reverse(); _controllers[config.currentIndex].forward(); } }