Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk3 min

Flutter’s context.value and context.state: When Each One Rebuilds

BlocSignal’s context.value returns raw state for a widget build that should respond to emissions; context.state returns a ReadonlySignal for downstream reactive composition.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In BlocSignal’s Flutter bindings, use context.value<B, S>() when the current widget’s build needs the raw state and should respond to emissions. Use context.state<B, S>() when you need the underlying ReadonlySignal<S> for reactive composition; looking it up does not, by itself, register the calling widget element to rebuild on every state emission. These are extensions from bloc_signals_flutter, not methods built into Flutter’s BuildContext.

What each method returns

The names distinguish two forms of the same state. context.value<B, S>() returns the current state as a plain S. context.state<B, S>() returns a ReadonlySignal<S>, preserving the reactive signal rather than unwrapping its current value. The BlocSignal Flutter API documentation shows both patterns: bloc_signals_flutter API documentation.

As an Amazon Associate I earn from qualifying purchases.

Call Returns Use it when Widget-element behavior
context.value<B, S>() Current raw state, type S The widget’s build reads the state and should reflect its emissions The calling element registers a state dependency and rebuilds for emissions
context.state<B, S>() Underlying ReadonlySignal<S> You want to compose the signal with reactive constructs such as computed() or effect() The lookup itself does not register an element rebuild dependency

Here, B is the BlocSignal type and S is its state type. The context extensions provide access to state associated with the widget’s context; they do not change the state’s type or turn a raw value into a signal.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When to use context.value

Use context.value when the build method directly displays or otherwise uses the current state. The calling widget element then responds to state emissions, so its next build can produce output from the updated value.

final count = context.value<CounterCubit, int>();
return Text('Count: $count');

This is the straightforward choice for a widget whose own rendered output depends on the current value. It is not a general-purpose promise that a particular application architecture will rebuild only one widget or perform better: the package documentation establishes the subscription behavior of the extension, not comparative performance across app designs.

When to use context.state

Use context.state when a downstream reactive construct should consume the signal. Getting the signal does not subscribe the calling widget element for rebuilds; the reactive computation or effect is where the signal is used.

final counterSignal = context.state<CounterCubit, int>();
final isEven = computed(() => counterSignal.value.isEven);

In this example, counterSignal remains a signal, and computed() derives a value from it. The reactive consumer is responsible for responding to changes. Simply obtaining the signal in a widget does not make that widget rebuild on every state emission.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why provide both names?

The pair makes the consumer’s intent visible at the call site: value asks for the unwrapped state, while state asks for the signal. That distinction matches the container-level naming. The bloc_signals 1.4.0 changelog records container.value as an alias for container.stateValue, aligning it with container.state and the Flutter context extensions: bloc_signals changelog.

The bloc_signals_flutter changelog records the addition of both context APIs in version 1.3.0. Its entry describes context.state<T, S>() as looking up the underlying ReadonlySignal<S> without registering an element rebuild dependency, for composition with computed() or effect(). The package API documentation showed version 1.3.2 when reviewed; check the package’s current documentation and compatibility requirements when choosing a dependency version: bloc_signals_flutter changelog.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choosing for a widget tree

Make the choice according to where the state should be consumed, not merely which name looks shorter:

  • Choose context.value when the current element’s build output directly depends on the raw state.
  • Choose context.state when you need to pass a signal into a reactive computation or effect and want that downstream consumer to handle changes.

Keeping a state-dependent read close to the widget that renders it can make rebuild intent easier to see. BlocSignal’s article also illustrates using Flutter’s Builder to scope a read to a nested element and composing signals from multiple containers. Those are architectural examples, not evidence of a quantified speedup or a universal guarantee about which elements rebuild; validate behavior against the BlocSignal and Flutter versions used by your application.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.