zoukankan      html  css  js  c++  java
  • flutter 显示HTML代码

    需求是后台返回的是富文本,所以需要吧富文本转成flutter 能识别的内容 找了几个插件只有这个比较好用写下来

    dependencies:  flutter_html: ^0.9.8 安装 下剩下的就比较简单了
    import 'package:flutter_html/flutter_html.dart'; 引入
    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>
      """,
      //Optional parameters:
      padding: EdgeInsets.all(8.0),
      backgroundColor: Colors.white70,
      defaultTextStyle: TextStyle(fontFamily: 'serif'),
      linkStyle: const TextStyle(
        color: Colors.redAccent,
      ),
      onLinkTap: (url) {
        // open url in a webview
      },
      customRender: (node, children) {
        if(node is dom.Element) {
          switch(node.localName) {
            case "video": return Chewie(...);
            case "custom_tag": return CustomWidget(...);
          }
        }
      },
    )
  • 相关阅读:
    网络摄像头RTSP协议视频平台EasyNVR升级版本后如何迁移原版数据?
    ubuntu下安装dosbox
    动态数组
    C风格字符串
    指针
    数组
    bitset
    迭代器iterator
    vector
    string--getline(),cctype
  • 原文地址:https://www.cnblogs.com/wupeng88/p/10881447.html
Copyright © 2011-2022 走看看