call method

Widget call(
  1. Widget builder(
    1. BuildContext context,
    2. BloomVia via
    ), {
  2. Key? key,
})

Creates an inline reactive widget that tracks dependencies dynamically and explicitly via BloomVia.

Requires:

  • builder must be a pure, declarative function without synchronous state mutations.

Ensures:

  • Returns a lightweight reactive Widget bound to the active BloomVia tracking scope.

Warning (Anti-Pattern Prevention):

  • Do NOT read untracked values directly inside builder without wrapping in via(...). Directly calling untracked(...) performs an untracked read and bypasses reactive invalidations.
  • Do NOT trigger state mutations inside builder, as this violates Flutter's single-pass render contract.

BAD:

// [Anti-Pattern] Reading untracked directly inside composed
Widget build(BuildContext context) {
  return composed((context, via) => Text('Count: ${untracked(counter.bloom)}')); // NEVER rebuilds!
}

GOOD:

// [Recommended] Explicitly observe via(node)
Widget build(BuildContext context) {
  return composed((context, via) => Text('Count: ${via(counter.bloom)}')); // Dynamically tracked
}

Examples

composed((context, via) {
  final user = via(userBloom);
  return Text('Hello, ${user.name}');
});

Implementation

@pragma('vm:prefer-inline')
Widget call(
  Widget Function(BuildContext context, BloomVia via) builder, {
  Key? key,
}) =>
    _ComposedWidget(builder, key: key);