Html constructor

Html({
  1. Key? key,
  2. GlobalKey<State<StatefulWidget>>? anchorKey,
  3. required String? data,
  4. OnTap? onLinkTap,
  5. OnTap? onAnchorTap,
  6. Map<String, CustomRender> customRender = const {},
  7. Map<ImageSourceMatcher, ImageRender> customImageRenders = const {},
  8. OnCssParseError? onCssParseError,
  9. ImageErrorListener? onImageError,
  10. OnMathError? onMathError,
  11. bool shrinkWrap = false,
  12. OnTap? onImageTap,
  13. List<String> tagsList = const [],
  14. Map<String, Style> style = const {},
  15. NavigationDelegate? navigationDelegateForIframe,
})

The Html widget takes HTML as input and displays a RichText tree of the parsed HTML content.

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. customRender This function allows you to return your own widgets for existing or custom HTML tags. See its wiki page for more info.

onImageError This is called whenever an image fails to load or display on the page.

shrinkWrap This makes the Html widget take up only the width it needs and no more.

onImageTap This is called whenever an image is tapped.

tagsList Tag names in this array will be the only tags rendered. By default all tags are rendered.

style Pass in the style information for the Html here. See its wiki page for more info.

Implementation

Html({
  Key? key,
  GlobalKey? anchorKey,
  required this.data,
  this.onLinkTap,
  this.onAnchorTap,
  this.customRender = const {},
  this.customImageRenders = const {},
  this.onCssParseError,
  this.onImageError,
  this.onMathError,
  this.shrinkWrap = false,
  this.onImageTap,
  this.tagsList = const [],
  this.style = const {},
  this.navigationDelegateForIframe,
})  : document = null,
      assert(data != null),
      _anchorKey = anchorKey ?? GlobalKey(),
      super(key: key);