Recipes

Rebuild only the required Flutter value

Choose Builder or Selector according to the UI value that must react.

v0.1.0-dev.1Intermediateusecase_forge_flutter
Open source reference

Rebuild only the required Flutter value

Use UseCaseBuilder when the widget needs the complete UseCaseSnapshot. Use UseCaseSelector when it needs one derived value and should ignore unrelated Snapshot changes.

dart
UseCaseSelector<CartUseCase, CartState, int>(
  selector: (snapshot) => snapshot.state.items.length,
  builder: (context, itemCount) => Badge(label: Text('$itemCount')),
)

The selector runs for every emitted Snapshot, but the builder runs only when the selected value changes by ==. Select a small immutable value with meaningful equality.

Use buildWhen on UseCaseBuilder when the decision needs both the previous and current Snapshot. Do not copy State into a second widget-owned model merely to avoid rebuilds; that creates competing sources of truth.

ARKTELOS

Purpose-built engineering systems for software that has to hold.