JuiceBuilder<TBloc extends JuiceBloc<BlocState> > class
A builder widget that reactively rebuilds in response to bloc state changes.
JuiceBuilder provides a composable way to build widgets that depend on a bloc's state, without requiring inheritance. It can be used inline anywhere in the widget tree.
Example:
JuiceBuilder<CounterBloc>(
groups: {'counter'},
builder: (context, bloc, status) {
return Text('Count: ${bloc.state.count}');
},
)
For conditional rebuilding, use buildWhen:
JuiceBuilder<CounterBloc>(
buildWhen: (status) => bloc.state.count.isEven,
builder: (context, bloc, status) {
return Text('Even count: ${bloc.state.count}');
},
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- JuiceBuilder
Constructors
-
JuiceBuilder({Key? key, required Widget builder(BuildContext context, TBloc bloc, StreamStatus<
BlocState> status), Set<String> groups = const {'*'}, bool buildWhen(StreamStatus<BlocState> status)?, BlocDependencyResolver? resolver, VoidCallback? onInit, VoidCallback? onDispose}) -
Creates a JuiceBuilder.
const
Properties
-
builder
→ Widget Function(BuildContext context, TBloc bloc, StreamStatus<
BlocState> status) -
Builds the widget based on the current bloc state.
final
-
buildWhen
→ bool Function(StreamStatus<
BlocState> status)? -
Optional condition to determine if the widget should rebuild.
Return false to skip rebuilding for a state change.
final
-
groups
→ Set<
String> -
Groups that control when this widget rebuilds.
Default is
{'*'}which means rebuild on all state changes.final - hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- onDispose → VoidCallback?
-
Called when the widget is disposed.
final
- onInit → VoidCallback?
-
Called when the widget is first initialized.
final
- resolver → BlocDependencyResolver?
-
Optional custom bloc resolver. Defaults to global resolver.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< JuiceBuilder< TBloc> > -
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