ContextualBlockRenderer typedef

ContextualBlockRenderer = Widget Function(List<MarkdownNode> nodes, {MarkdownRenderContext? context})

Context-aware variant of BlockRenderer.

The renderer's internal closure implements this so that builders can override the MarkdownRenderContext for their rendered children (for example an HTML block that applies text alignment). That closure backs both typedefs: it matches ContextualBlockRenderer exactly, and because a function accepting an optional context is also assignable to the single-argument BlockRenderer (callers that omit context still work), the same closure can populate MarkdownRenderContext.blockRenderer as well.

This typedef is intentionally additive so the public BlockRenderer stays single-argument and existing (nodes) => widget callbacks remain assignable to it. The subtyping runs one direction only: a plain single-argument callback is not assignable to ContextualBlockRenderer (it could not honor a context override), which is why builders that need the override go through this typedef rather than BlockRenderer.

Implementation

typedef ContextualBlockRenderer = Widget Function(
  List<MarkdownNode> nodes, {
  MarkdownRenderContext? context,
});