BlocSelector<B extends StateStreamable<S> , S, T> constructor
const
BlocSelector<B extends StateStreamable<S> , S, T> ({
- required BlocWidgetSelector<
S, T> selector, - required BlocWidgetBuilder<
T> builder, - Key? key,
- B? bloc,
BlocSelector is analogous to BlocBuilder but allows developers to filter updates by selecting a new value based on the bloc state. Unnecessary builds are prevented if the selected value does not change.
Note: the selected value must be immutable in order for BlocSelector to accurately determine whether builder should be called again.
BlocSelector<BlocA, BlocAState, SelectedState>(
selector: (state) {
// return selected state based on the provided state.
},
builder: (context, state) {
// return widget here based on the selected state.
},
)
Implementation
const BlocSelector({
required this.selector,
required this.builder,
Key? key,
this.bloc,
}) : super(key: key);