搜索插件、代码仓与 APP 分类

插件详情v0.5.12

flutter_html_view

Flutter 插件用于渲染 HTML,Flutter 默认不支持渲染 HTML,因此此包可帮助您将 HTML 渲染为原生控件

近 30 天下载
131
喜欢数
26
Pub 分数
40

安装插件

flutter pub add flutter_html_view

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 插件,可在 Flutter 应用中将 HTML 内容渲染为原生小部件。由于 Flutter 不原生支持 HTML 渲染,此包通过解析 HTML 字符串并将它们转换为相应的 Flutter 小部件来填补这一空白。它支持基本的 HTML 标签和 CSS 样式,非常适合显示格式化文本、博客文章或来自网络源的动态内容。该包轻量且可无缝集成到现有的 Flutter 项目中。

适合场景

  • 显示格式化的博客内容
  • 从 API 渲染动态 HTML
  • 在应用中显示富文本
  • 嵌入用户生成的HTML
  • 创建简单的类似网页的界面

主要特点

  • HTML 到 Widget 的转换
  • 基本 CSS 支持
  • 轻量且快速
  • 与 Flutter 的轻松集成
  • 支持常见的 HTML 标签

适合对象

  • 需要丰富文本显示的应用
  • 内容密集型应用
  • 简单的网页内容渲染
  • 处理 HTML 数据的开发者
  • 依赖项最少的项目

使用建议

  • 有限的高级CSS支持
  • 无 JavaScript 执行
  • 不适合复杂的网页
  • 不受信任的HTML的安全风险
  • 性能可能随着大型 HTML 内容而下降

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

flutter_html_view

Flutter Plugin to render html as a Widget,

Refer this for full support of inline webview for android and iOS

Flutter has no default support to render html so this package helps you to render your html to native widgets

  • Video tag support added
  • Links are clickable now

Supported Tags

  • p
  • em
  • b
  • img
  • video
  • h1, h2, h3, h4, h5, h6

Note

  • This plugin converts some of the html tags to flutter widgets
  • This plugin does't support rendering full html code (there is no built in support for web rendering in flutter)

How to Use

dependencies:
  flutter_html_view: ^0.5.11

import 'package:flutter_html_view/flutter_html_view.dart';

String html = '<body>Hello world! <a href="www.html5rocks.com">HTML5 rocks!';

new HtmlView(
  data: html,
  baseURL: "", // optional, type String
  onLaunchFail: (url) { // optional, type Function
    print("launch $url failed");
  },
  scrollable: false, //false to use MarksownBody and true to use Marksown
)

MarkdownStyleSheet

styleSheet: MarkdownStyleSheet(

),
styleOptions

The default and available style options:

Name Default Options
headingStyle "setext" "setext", "atx"
hr "* * *" "* * *", "- - -", "_ _ _"
bulletListMarker "*" "*", "-", "_"
codeBlockStyle "indented" "indented", "fenced"
fence "```" "```", "~~~"
emDelimiter "_" "_", "*"
strongDelimiter "**" "**", "__"
linkStyle "inlined" "inlined", "referenced"
linkReferenceStyle "full" "full", "collapsed", "shortcut"
iOS

Warning: The video player is not functional on iOS simulators. An iOS device must be used during development/testing.

Add the following entry to your Info.plist file, located in <project root>/ios/Runner/Info.plist:

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>

This entry allows your app to access video files by URL.

Android

Ensure the following permission is present in your Android Manifest file, located in `/android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET"/>

Thanks to

@Katran

所属分类

依赖

依赖清单 6 项

源码仓库

使用此插件的项目