HTML5 constructor

HTML5({
  1. Key? key,
  2. GlobalKey<State<StatefulWidget>>? anchorKey,
  3. required String? data,
  4. OnTap? onLinkTap,
  5. OnTap? onAnchorTap,
  6. Map<CustomRenderMatcher, CustomRender> customRenders = const {},
  7. OnCssParseError? onCssParseError,
  8. ImageErrorListener? onImageError,
  9. bool shrinkWrap = false,
  10. OnTap? onImageTap,
  11. List<String> tagsList = const [],
  12. Map<String, CSS3> style = const {},
})

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 supported HTML tags are rendered.

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

Implementation

HTML5({
  Key? key,
  GlobalKey? anchorKey,
  required this.data,
  this.onLinkTap,
  this.onAnchorTap,
  this.customRenders = const {},
  this.onCssParseError,
  this.onImageError,
  this.shrinkWrap = false,
  this.onImageTap,
  this.tagsList = const [],
  this.style = const {},
})  : documentElement = null,
      assert(data != null),
      _anchorKey = anchorKey ?? GlobalKey(),
      super(key: key);