JuiceSelector<TBloc extends JuiceBloc<TState> , TState extends BlocState, T> class
A widget that rebuilds only when a selected portion of state changes.
A leaf optimization inside the rebuild-groups vocabulary: with groups, the widget rebuilds when an emission targets one of its groups AND the selected value changed — "in this group's blast radius, only if this cell moved". That is the shape for a hot cell (a list row's one field, a ticker) under a group that covers a whole section. Without groups every emission is compared, which works but leaves the invalidation unnamed.
Precondition: T needs value equality; see JuiceSelectorWith for
collections.
Example:
JuiceSelector<CounterBloc, CounterState, int>(
groups: {CounterGroups.display},
selector: (state) => state.count,
builder: (context, count) => Text('Count: $count'),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- JuiceSelector
Constructors
-
JuiceSelector({Key? key, required T selector(TState state), required Widget builder(BuildContext context, T value), TBloc? bloc, Set<
String> ? groups}) -
Creates a JuiceSelector.
const
Properties
- bloc → TBloc?
-
Optional bloc instance. If not provided, looks up from BlocScope.
final
- builder → Widget Function(BuildContext context, T value)
-
Function that builds the widget using the selected value.
final
-
groups
→ Set<
String> ? -
Rebuild groups to listen in. When given, only emissions targeting one of
these groups are considered (then the selected value is compared). When
null, every emission is considered.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selector → T Function(TState state)
-
Function that extracts the value of interest from state.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< JuiceSelector< TBloc, TState, T> > -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited