EmbedWebView constructor

EmbedWebView(
  1. String webViewContent, {
  2. double? width,
  3. double? maxHeight,
  4. String? fontSize,
  5. String? backgroundColor,
  6. String? lineHeight,
  7. bool forceExpandImageWidget = false,
})

A widget that displays a WebView in Flutter Web. The srcDoc property must be set to a valid HTML document. example:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>
    </title>
  </head>

  <body>
  </body>

</html>

@param webViewContent: web view content 页面间传递中文需要用Uri.encodeComponent转换, 否则就报Invalid argument(s): Illegal percent encoding in URI异常 @param width: the width of the webview, if null, the width will be as wide as it can be @param maxHeight 最大高度,超出则滑动WebView,没有则不限制高度 @param fontSize: 网页文本的字体大小,如"4vw",不指定则用默认的大小 @param backgroundColor 网页的背景颜色,格式为#RRGGBB,默认白色 @param forceExpandImageWidget: force expand image widget's width and height to fit the screen

Implementation

EmbedWebView(this.webViewContent,
    {this.width,
    this.maxHeight,
    this.fontSize,
    this.backgroundColor,
    this.lineHeight,
    this.forceExpandImageWidget = false}) {
  if (webViewContent.isNotEmpty) {
    webViewContent = Uri.encodeComponent(webViewContent);
  }
}