SelectableHtml constructor
The SelectableHtml
widget takes HTML as input and displays a RichText
tree of the parsed HTML content (which is selectable)
Attributes
data required takes in a String of HTML data (required only for Html
constructor).
document required takes in a Document of HTML data (required only for Html.fromDom
constructor).
onLinkTap This function is called whenever a link (<a href>
)
is tapped.
onAnchorTap This function is called whenever an anchor (#anchor-id) is tapped.
tagsList Tag names in this array will be the only tags rendered. By default all tags that support selectable content are rendered.
style Pass in the style information for the Html here. See its wiki page for more info.
PLEASE NOTE
There are a few caveats due to Flutter #38474:
-
The list of tags that can be rendered is significantly reduced. Key omissions include no support for images/video/audio, table, and ul/ol because they all require widgets and
WidgetSpan
s. -
No support for
customRender
,customImageRender
,onImageError
,onImageTap
,onMathError
, andnavigationDelegateForIframe
. -
Styling support is significantly reduced. Only text-related styling works (e.g. bold or italic), while container related styling (e.g. borders or padding/margin) do not work because we can't use the
ContainerSpan
class (it needs an enclosingWidgetSpan
).
Implementation
SelectableHtml({
Key? key,
required this.data,
this.onLinkTap,
this.onAnchorTap,
this.onCssParseError,
this.shrinkWrap = false,
this.style = const {},
this.tagsList = const [],
}) : document = null,
super(key: key);