call<T> method

Widget call<T>(
  1. T onTick(
    1. Duration elapsed
    ),
  2. Widget builder(
    1. BuildContext context,
    2. BloomVia via,
    3. T value
    ), {
  3. Key? key,
})

Creates an inline reactive widget driven by a continuous frame ticker.

Converts continuous elapsed duration pulses from a frame ticker into reactive state of type T via onTick, re-evaluating builder synchronously on each frame tick.

  • onTick: Callback converting frame elapsed duration to state of type T. Evaluated synchronously with Duration.zero to seed initial state, and subsequently on frame ticks.
  • builder: Reactive builder callback receiving BuildContext, BloomVia, and current driven value T.
  • key: Optional widget key.

Requires:

  • onTick must be a pure, deterministic conversion function.

Ensures:

  • Returns an inline reactive Widget driven continuously by element frame ticks.

Examples

composed.drive<double>(
  (elapsed) => (elapsed.inMilliseconds % 1000) / 1000.0,
  (context, via, progress) => CircularProgressIndicator(value: progress),
);

Implementation

@pragma('vm:prefer-inline')
Widget call<T>(
  T Function(Duration elapsed) onTick,
  Widget Function(BuildContext context, BloomVia via, T value) builder, {
  Key? key,
}) =>
    _ComposedDriveWidget<T>(
      onTick: onTick,
      builder: builder,
      key: key,
    );