flutter_widget_from_html 0.1.5

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 91

Flutter Widget from HTML #

CircleCI codecov Pub

A Flutter plugin for building Flutter-widget tree from html.

This package extends the flutter_widget_from_html_core package with extra functionalities by using external depedencies like cached_network_image or url_launcher. It should be good enough as a quick starting point but you can always use the core directly if you dislike the dependencies.

Usage #

To use this plugin, add flutter_widget_from_html as a dependency in your pubspec.yaml file.

See the Example app for inspiration.

Example #

Note: HtmlWidget.config is optional, see dartdoc for all available configuration keys and their default values.

class HelloWorldScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) => Scaffold(
      appBar: AppBar(
        title: Text('HelloWorldScreen'),
      ),
      body: ListView(
        children: <Widget>[
          HtmlWidget("""<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
<p>A paragraph with <strong>strong</strong> <em>emphasized</em> text.</p>
<p>And of course, cat image: <img src="https://media.giphy.com/media/6VoDJzfRjJNbG/giphy-downsized.gif" /></p>
<div style="text-align: center">Source: <a href="https://gph.is/QFgPA0">https://gph.is/QFgPA0</a></div>
"""),
        ],
      ));
}

Features #

HTML tags #

Below tags are the ones that have special meaning / styling, all other tags will be parsed as text. All texts will be rendered with padding (Config.textPadding).

  • A: underline with theme accent color, launch url via url_launcher, support base url resolver
  • B
  • BR
  • CODE
  • DIV
  • EM
  • H1/H2/H3/H4/H5/H6
  • I
  • IFRAME via WebView. Available configurations:
    • Config.webView, default=false
    • Config.webViewJs, default=true
    • Config.webViewPadding
    • To render IFRAME as web view: set webView=true in config and setup iOS project manually.
    • Web view will be rendered in a 16:9 box unless width and height attributes are specified in the IFRAME.
  • IMG via CachedNetworkImage with padding (Config.imagePadding), support base url resolver
  • LI/OL/UL with marker and padding (Config.listBullet, Config.listPaddingLeft)
  • P
  • PRE
  • STRONG
  • U

These tags and their contents will be ignored:

  • SCRIPT
  • STYLE

Inline stylings #

  • color: hex values only (#F00, #0F08, #00FF00 or #00FF0080)
  • font-family
  • font-size (value in px only)
  • font-style: italic/normal
  • font-weight: bold/normal/100..900
  • margin, margin-top, margin-right, margin-bottom, margin-left (values in px only)
  • text-align: center/justify/left/right
  • text-decoration: line-through/none/overline/underline

Extensibility #

See flutter_widget_from_html_core for details.

0.1.5 #

  • Fix margin with partial invalid values (#21)

0.1.4 #

  • Update dependencies (#12)
  • Add support for web view (#19)

0.1.3 #

  • Update flutter_widget_from_html_core 0.1.3

0.1.2 #

  • Update flutter_widget_from_html_core 0.1.2

0.1.1 #

  • Update flutter_widget_from_html_core 0.1.1

0.0.1 #

  • First release

example/README.md

example #

See the full Example app for inspiration.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_widget_from_html: ^0.1.5

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
  
Version Uploaded Documentation Archive
0.1.5 Apr 14, 2019 Go to the documentation of flutter_widget_from_html 0.1.5 Download flutter_widget_from_html 0.1.5 archive
0.1.4 Apr 1, 2019 Go to the documentation of flutter_widget_from_html 0.1.4 Download flutter_widget_from_html 0.1.4 archive
0.1.3 Mar 5, 2019 Go to the documentation of flutter_widget_from_html 0.1.3 Download flutter_widget_from_html 0.1.3 archive
0.1.2 Mar 5, 2019 Go to the documentation of flutter_widget_from_html 0.1.2 Download flutter_widget_from_html 0.1.2 archive
0.1.1 Feb 9, 2019 Go to the documentation of flutter_widget_from_html 0.1.1 Download flutter_widget_from_html 0.1.1 archive
0.1.0 Oct 19, 2018 Go to the documentation of flutter_widget_from_html 0.1.0 Download flutter_widget_from_html 0.1.0 archive
0.0.2 Oct 19, 2018 Go to the documentation of flutter_widget_from_html 0.0.2 Download flutter_widget_from_html 0.0.2 archive
0.0.1 Oct 18, 2018 Go to the documentation of flutter_widget_from_html 0.0.1 Download flutter_widget_from_html 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
83
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
91
Learn more about scoring.

We analyzed this package on Apr 18, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14
  • Flutter: 1.4.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

48 out of 48 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
cached_network_image ^0.7.0 0.7.0
flutter 0.0.0
flutter_widget_from_html_core ^0.1.5 0.1.5
html ^0.13.4 0.13.4+2 0.14.0+1
url_launcher ^5.0.2 5.0.2
webview_flutter ^0.3.5+2 0.3.5+4
Transitive dependencies
async 2.2.0
charcode 1.1.2
collection 1.14.11
convert 2.1.1
crypto 2.0.6
csslib 0.15.0
flutter_cache_manager 0.3.2
http 0.12.0+2
http_parser 3.1.3
meta 1.1.6 1.1.7
path 1.6.2
path_provider 0.5.0+1
pedantic 1.5.0
sky_engine 0.0.99
source_span 1.5.5
sqflite 1.1.5
string_scanner 1.0.4
synchronized 2.1.0
term_glyph 1.1.0
typed_data 1.1.6
utf 0.9.0+5
uuid 2.0.1
vector_math 2.0.8
Dev dependencies
flutter_test