SmoothMarkdown constructor

const SmoothMarkdown({
  1. required String data,
  2. Key? key,
  3. MarkdownStyleSheet? styleSheet,
  4. MarkdownConfig? config,
  5. void onTapLink(
    1. String url
    )?,
  6. Widget imageBuilder(
    1. String url,
    2. String? alt,
    3. String? title
    )?,
  7. Widget codeBuilder(
    1. String code,
    2. String? language
    )?,
  8. bool useEnhancedComponents = false,
  9. bool enableCache = true,
  10. bool useRepaintBoundary = true,
  11. ParserPluginRegistry? plugins,
  12. BuilderRegistry? builderRegistry,
})

Creates a widget that renders Markdown content.

The data parameter is required and contains the Markdown text to render.

All other parameters are optional and provide customization options:

  • styleSheet: Controls the visual styling of markdown elements. Defaults to MarkdownStyleSheet.light if not provided.
  • config: Configuration options for markdown parsing behavior. Most features are enabled by default.
  • onTapLink: Callback function invoked when a link is tapped. Receives the URL as a string parameter.
  • imageBuilder: Custom widget builder for rendering images. If not provided, uses the default image renderer with network caching.
  • codeBuilder: Custom widget builder for rendering code blocks. If not provided, uses the default code block renderer with syntax highlighting.
  • useEnhancedComponents: When true, uses enhanced UI components with additional visual effects and interactions. Defaults to false.

Example:

SmoothMarkdown(
  data: '# Title\n\nThis is **bold** text.',
  styleSheet: MarkdownStyleSheet.github(),
  useEnhancedComponents: true,
  onTapLink: (url) => launchUrl(Uri.parse(url)),
)

Implementation

const SmoothMarkdown({
  required this.data,
  super.key,
  this.styleSheet,
  this.config,
  this.onTapLink,
  this.imageBuilder,
  this.codeBuilder,
  this.useEnhancedComponents = false,
  this.enableCache = true,
  this.useRepaintBoundary = true,
  this.plugins,
  this.builderRegistry,
});