build method
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 target = via.state(bloom);
switch (target.phase) {
case BloomPhase.valid:
if (!preserveDataOnPending && via(pending)) {
return loading(context);
}
return _buildData(context, target.data);
case BloomPhase.error:
return _buildError(context, target.error, target.stackTrace);
case BloomPhase.empty:
final isPending = via(pending);
if (isPending) {
return loading(context);
}
return empty != null ? empty!(context) : loading(context);
}
}