child method

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

Creates an inline reactive widget with an isolated static child subtree.

Prevents redundant widget reconstructions by passing child into builder as a pre-constructed, cached subtree. When reactive dependencies mutate, only the outer container evaluates while child bypasses re-evaluation.

  • builder: Reactive builder callback receiving BuildContext, BloomVia, and cached child.
  • child: The static subtree to preserve across rebuilds. Must not be null.
  • key: Optional widget key.

Requires:

  • builder must be a pure, declarative function.

Ensures:

  • Returns a reactive Widget preserving child across dependency-driven rebuilds.

Examples

composed.child(
  (context, via, child) => Padding(
    padding: EdgeInsets.all(via(paddingBloom)),
    child: child,
  ),
  child: const ExpensiveGraphicWidget(),
);

Implementation

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