build method

  1. @override
Widget build(
  1. BuildContext context,
  2. BloomVia via
)
override

Describes the part of the user interface represented by this widget, with explicit BloomVia tracking.

  • context: The active Flutter BuildContext representing this widget's location in the element tree.
  • via: The injected BloomVia tracker used to dynamically and explicitly discover reactive dependencies.

Requires:

  • build must be a pure, declarative function without mutations or unhandled asynchronous scheduling.

Ensures:

  • Returns a Widget representing the current reactive user interface.

Implementation

@override
Widget build(BuildContext context, BloomVia via) {
  final isPending = via(target);

  if (builder != null) {
    return builder!(context, isPending);
  }

  if (!isPending) {
    return SizedBox(height: height);
  }

  return SizedBox(
    height: height,
    child: composed.drive<double>(
      (elapsed) => (elapsed.inMicroseconds % 1200000) / 1200000.0,
      (context, via, progress) => CustomPaint(
        size: Size(double.infinity, height),
        painter: _PendingBarPainter(
          progress: progress,
          color: color ?? const Color(0xFF2196F3),
          backgroundColor: backgroundColor ?? const Color(0x00000000),
        ),
      ),
    ),
  );
}