StatelessJuiceWidget<TBloc extends JuiceBloc<BlocState>> class abstract

Base class for creating stateless widgets that reactively respond to Juice bloc state changes.

StatelessJuiceWidget provides a structured way to build widgets that depend on a single bloc's state, with support for selective rebuilding through groups and lifecycle management.

Type Parameters:

  • TBloc - The type of bloc this widget observes

Example:

class CounterDisplay extends StatelessJuiceWidget<CounterBloc> {
  CounterDisplay({super.key, super.groups = const {"counter"}});

  @override
  Widget onBuild(BuildContext context, StreamStatus status) {
    return Text(
      'Count: ${bloc.state.count}',
      style: Theme.of(context).textTheme.headline4,
    );
  }
}
Inheritance

Constructors

StatelessJuiceWidget({Key? key, BlocDependencyResolver? resolver, Set<String> groups = const {"*"}, Object? scope})
Creates a StatelessJuiceWidget with optional resolver and rebuild groups.

Properties

bloc → TBloc
The bloc instance this widget observes.
no setter
groups → Set<String>
Groups that control when this widget rebuilds. Default {'*'} rebuilds on emissions sent to EVERY widget (rebuildAlways, which is also what an emit without groupsToRebuild sends) — NOT on emissions targeted at named groups. Name the groups this widget shows to rebuild on those. This set is unmodifiable to preserve widget immutability.
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
scope → Object?
Optional scope key for resolving scoped bloc instances.
final

Methods

build(BuildContext context) → Widget
Describes the part of the user interface represented by this widget.
override
close(BuildContext context) → Widget
Called when the bloc stream is closed. Override to handle cleanup or show final UI state.
createElement() → StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
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
onBuild(BuildContext context, StreamStatus<BlocState> status) → Widget
Main build method to override. Constructs widget UI based on current status.
onInit() → void
Called when the widget is first initialized. Override to add initialization logic.
onStateChange(StreamStatus<BlocState> status) → bool
Called for each state change to determine if widget should rebuild. Return false to prevent rebuild for this state change.
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