imageBuilder property

Widget Function(String url, String? alt, String? title)? imageBuilder
final

Custom widget builder for rendering images.

This builder is called for each image in the markdown, receiving:

  • url: The image URL (can be network URL, asset path, or data URI)
  • alt: Alternative text for the image (null if not provided)
  • title: Image title attribute (null if not provided)

If not provided, images are rendered using the default image builder which supports network images with caching (via cached_network_image) and SVG images (via flutter_svg).

Example:

imageBuilder: (url, alt, title) {
  return GestureDetector(
    onTap: () => showImageViewer(url),
    child: CachedNetworkImage(
      imageUrl: url,
      placeholder: (context, url) => CircularProgressIndicator(),
      errorWidget: (context, url, error) => Icon(Icons.broken_image),
    ),
  );
}

Implementation

final Widget Function(String url, String? alt, String? title)? imageBuilder;