visitElementAfterWithContext method
Widget?
visitElementAfterWithContext(
- BuildContext context,
- Element element,
- TextStyle? preferredStyle,
- TextStyle? parentStyle,
Called when an Element has been reached, after its children have been visited.
If MarkdownWidget.styleSheet has a style with this tag, it will be
passed as preferredStyle.
If parent element has TextStyle set, it will be passed as
parentStyle.
If a widget build isn't needed, return null.
Implementation
@override
Widget? visitElementAfterWithContext(
BuildContext context,
md.Element element,
TextStyle? preferredStyle,
TextStyle? parentStyle,
) {
final code = _codeChild(element);
if (code == null) return null;
final source = _stripMarkdownTerminalNewline(code.textContent);
final language = markdownCodeLanguage(code);
if (language == 'mermaid' && source.trim().isNotEmpty) {
return MarkdownMermaidBlock(source: source, user: user);
}
return MarkdownCodeBlock(source: source, language: language, user: user);
}