小编Sai*_*hal的帖子

如何使用 flutter_html 包根据 html 标签渲染自定义小部件?

我有一个 HTML 文档,我想使用 flutter_html 插件通过 Flutter 渲染它。我想以不同的方式呈现不同的排版。例如。我想为粗体设置不同的字体和大小,为非粗体设置不同的字体和大小。

我尝试阅读文档,其中包含名为 的 Html 构造函数的属性customRenderer,但我无法理解它的实现。

以下是文档中的代码。

  Html(
    data: """
      <!--For a much more extensive example, look at example/main.dart-->
      <div>
        <h1>Demo Page</h1>
        <p>This is a fantastic nonexistent product that you should buy!</p>
        <h2>Pricing</h2>
        <p>Lorem ipsum <b>dolor</b> sit amet.</p>
        <h2>The Team</h2>
        <p>There isn't <i>really</i> a team...</p>
        <h2>Installation</h2>
        <p>You <u>cannot</u> install a nonexistent product!</p>
        <!--You can pretty much put any html in here!-->
      </div>
    """,
    padding: EdgeInsets.all(8.0),
    backgroundColor: Colors.white70,
    defaultTextStyle: TextStyle(fontFamily: 'serif'),
    linkStyle: const TextStyle( …
Run Code Online (Sandbox Code Playgroud)

html-rendering flutter

6
推荐指数
1
解决办法
6728
查看次数

标签 统计

flutter ×1

html-rendering ×1