DmMarkdown class
A standalone read-only markdown renderer.
Accepts one of three input modes:
- data: Raw markdown string — parsed internally.
- nodes: Pre-parsed AST nodes — renders directly (no parse step).
- stream: Streaming markdown chunks — incrementally parsed.
Features include GFM, KaTeX math, syntax-highlighted code, scroll-to-anchor, selectable text, and custom theme override.
DmMarkdown(data: '# Hello\n\nSome **bold** text')
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- DmMarkdown
Constructors
-
DmMarkdown({Key? key, String? data, List<
Node> ? nodes, Stream<String> ? stream, DmMarkdownConfig config = const DmMarkdownConfig(), ScrollController? controller, bool selectable = true, bool shrinkWrap = false, ScrollPhysics? physics, EdgeInsets? padding, ThemeData? themeData, void onLinkTap(String url, String? title)?, void onImageTap(String url, String? title)?, Widget imageErrorBuilder(String src, String? alt)?}) -
Creates a markdown widget. Exactly one of
data,nodes, orstreammust be provided.const
Properties
- config → DmMarkdownConfig
-
Rendering configuration (features, code theme, custom builders).
final
- controller → ScrollController?
-
Scroll controller for the internal ListView.
Pass a DmMarkdownScrollController to enable anchor navigation.
final
- data → String?
-
Raw markdown string — parsed internally.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- imageErrorBuilder → Widget Function(String src, String? alt)?
-
Custom widget shown when an image fails to load.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
nodes
→ List<
Node> ? -
Pre-parsed AST nodes — skips parsing. Used by DmMarkdownInput.
final
- onImageTap → void Function(String url, String? title)?
-
Called when an image is tapped.
final
- onLinkTap → void Function(String url, String? title)?
-
Called when a link is tapped. If null, defaults to
url_launcher.final - padding → EdgeInsets?
-
Padding around the rendered content.
final
- physics → ScrollPhysics?
-
Scroll physics override.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selectable → bool
-
Wrap content in SelectionArea for text selection. Defaults to
true.final - shrinkWrap → bool
-
If
true, the ListView uses shrinkWrap (for embedding in Column/scroll).final -
stream
→ Stream<
String> ? -
Streaming markdown input — incrementally parsed as chunks arrive.
Ideal for LLM output rendering.
final
- themeData → ThemeData?
-
Optional theme override — wraps rendering in a Theme widget.
If null, uses the ambient Theme.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< DmMarkdown> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited