visitElementAfterWithContext method

  1. @override
Widget? visitElementAfterWithContext(
  1. BuildContext context,
  2. Element element,
  3. TextStyle? preferredStyle,
  4. TextStyle? parentStyle,
)
override

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 src = element.attributes['src'] ?? '';
  final alt = element.attributes['alt'] ?? '';

  if (src.isEmpty) return null;

  return _ChunkImage(src: src, alt: alt);
}