void _addBlockChild(Widget child) { Assert.IsTrue(_blocks.Count > 0, "_blocks.Count > 0"); _BlockElement parent = _blocks.last(); if (parent.children.isNotEmpty()) parent.children.Add(new SizedBox(null, null, styleSheet.blockSpacing)); parent.children.Add(child); parent.nextListIndex += 1; }
public override void visitElementAfter(markdown.Element element) { string tag = element.tag; if (_isBlockTag(tag)) { _addAnonymousBLockIfNeeded(styleSheet.styles(tag)); _BlockElement current = _blocks.removeLast(); Widget child; if (current.children.isNotEmpty()) { child = new Column(null, null, null, MainAxisAlignment.start, MainAxisSize.max, CrossAxisAlignment.stretch, VerticalDirection.down, current.children); } else { child = new SizedBox(); } if (_isListTag(tag)) { Debug.Assert(_listIndents.isNotEmpty(), "_listIndents.isNotEmpty()"); _listIndents.removeLast(); } else if (tag == "li") { if (_listIndents.isNotEmpty()) { child = new Row( null, null, null, MainAxisAlignment.start, MainAxisSize.max, CrossAxisAlignment.start, VerticalDirection.down, new List<Widget>() { new SizedBox(null, styleSheet.listIndent, null, _buildBullet(_listIndents.last())), new Expanded(null, 1, child) }); } } else if (tag == "blockquote") { child = new DecoratedBox( null, styleSheet.blockquoteDecoration, DecorationPosition.background, new Padding( null, EdgeInsets.all(styleSheet.blockquotePadding), child)); } else if (tag == "pre") { child = new DecoratedBox( null, styleSheet.codeblockDecoration, DecorationPosition.background, new Padding( null, EdgeInsets.all(styleSheet.codeblockPadding), child)); } else if (tag == "hr") { child = new DecoratedBox( null, styleSheet.horizontalRuleDecoration, DecorationPosition.background, child); } _addBlockChild(child); } else { _InlineElement current = _inlines.removeLast(); _InlineElement parent = _inlines.last(); if (tag == "img") { current.children.Add(_buildImage(element.attributes["src"])); } else if (tag == "a") { _linkHandlers.removeLast(); } if (current.children.isNotEmpty()) { parent.children.AddRange(current.children); } } }