buildWhen property
An optional buildWhen can be implemented for more granular control over
how often LidBuilder rebuilds.
buildWhen will be invoked on each stateNotifier state
change.
buildWhen takes the previous state
and current state
and must
return a bool which determines whether or not the builder function will
be invoked.
The previous state
will be initialized to the state
of the stateNotifier when
the LidBuilder is initialized.
buildWhen is optional and if omitted, it will default true
if previous
state
is different current state
, otherwise is false
, however the
first time does not have an effect, always true
.
LidBuilder<StateType>(
stateNotifier: stateNotifier,
buildWhen: (previous, current) {
// return true/false to determine whether or not
// to rebuild the widget with state
},
builder: (context, state) {
// return widget here based on State Notifier's state
}
)
Implementation
final BuilderCondition<T>? buildWhen;