select<Result> method
Target<Notifier, Result>
select<Result>(
- _BuildBySelect<
S, Result> callback, { - bool booleanCallback = false,
use this method to rebuild your Consumer when a value in the state has changed or you can use a boolean condition. Check the documentation for more info.
booleanCallback
If your callback returns a boolean and you want to
rebuild your consumers or notify to your listeners only when the boolean
value is true you can set booleanCallback
as true
EXAMPLE:
final controller = ref.watch(
provider.select(
(_) => _.user != null,
booleanCallback: true,
),
);
Implementation
Target<Notifier, Result> select<Result>(
_BuildBySelect<S, Result> callback, {
bool booleanCallback = false,
}) {
final target = Target<Notifier, Result>(read);
target.filter = Filter.select;
target.callback = callback;
target.listenWhenTheCallbackReturnsTrue = booleanCallback;
return target;
}