render method

  1. @override
void render(
  1. Rect area,
  2. Buffer buffer,
  3. RenderContext ctx
)
override

Implementation

@override
void render(Rect area, Buffer buffer, RenderContext ctx) {
  if (!state.started) {
    state.started = true;
    final chainCtx = ChainFlowContext._(state, ctx.requestRedraw);
    flow(chainCtx).then((_) {
      if (state.cancelled) return;
      state.completed = true;
      state.currentWidget = null;
      state.currentCompleter = null;
      final values =
          state._history.map((e) => e.value).toList(growable: false);
      onComplete?.call(values);
      ctx.requestRedraw();
    }).catchError((Object e, StackTrace st) {
      if (e is ChainCancelled) return;
      onError?.call(e, st);
    });
  }

  if (state.cancelled) return;

  var y = area.y;
  for (final entry in state._history) {
    final h = _measure(entry.widget);
    final rect = Rect(area.x, y, area.width, h);
    ctx.draw(entry.widget, rect);
    y += h + spacing;
  }

  final current = state.currentWidget;
  if (current != null) {
    final h = _measure(current);
    final rect = Rect(area.x, y, area.width, h);
    ctx.draw(current, rect);
  }
}