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

Available extensions

Constructors

RebuildGroup(String name)
Creates a rebuild group with the given name.
const

Properties

hashCode int
The hash code for this object.
no setteroverride
name String
The string identifier for this group.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

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.