build method

List<Widget> build(
  1. List<Node> nodes
)

Returns widgets that display the given Markdown nodes.

The returned widgets are typically used as children in a ListView.

Implementation

List<Widget> build(List<md.Node> nodes) {
  _listIndents.clear();
  _blocks.clear();
  _tables.clear();
  _inlines.clear();
  _linkHandlers.clear();
  _isInBlockquote = false;

  builders.forEach((String key, MarkdownElementBuilder value) {
    if (value.isBlockElement()) {
      _kBlockTags.add(key);
    }
  });

  _blocks.add(_BlockElement(null));

  for (final md.Node node in nodes) {
    assert(_blocks.length == 1);
    node.accept(this);
  }

  assert(_tables.isEmpty);
  assert(_inlines.isEmpty);
  assert(!_isInBlockquote);
  return _blocks.single.children;
}