RebuildGroup class
A type-safe identifier for widget rebuild groups.
Use RebuildGroup to define compile-time safe rebuild groups instead of
magic strings. This provides IDE autocomplete, typo prevention, and
refactoring support.
Defining Groups
Define groups as static constants in a dedicated class per feature:
abstract class CounterGroups {
static const counter = RebuildGroup('counter');
static const display = RebuildGroup('counter:display');
static const buttons = RebuildGroup('counter:buttons');
}
Using in Use Cases
Convert to string set when emitting:
emitUpdate(
newState: newState,
groupsToRebuild: {CounterGroups.counter}.toStringSet(),
);
Using in Widgets
class CounterDisplay extends StatelessJuiceWidget<CounterBloc> {
CounterDisplay() : super(groups: {CounterGroups.display}.toStringSet());
}
Built-in Groups
- RebuildGroup.all - Triggers rebuild in all participating widgets
- RebuildGroup.optOut - Widget never rebuilds from bloc events
- Available extensions
Constructors
- RebuildGroup(String name)
-
Creates a rebuild group with the given
name.const
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toSet(
) → Set< String> -
Available on RebuildGroup, provided by the RebuildGroupExtension extension
Converts this single group to a set containing just its string name. -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Constants
- all → const RebuildGroup
- Special group that triggers rebuilds in all participating widgets.
- optOut → const RebuildGroup
- Special group that opts a widget out of all rebuilds.