use_html_t 1.0.0-pre.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 64

flutter_html #

pub package codecov CircleCI

A Flutter widget for rendering html and css as Flutter widgets.

A Screenshot of flutter_html

Installing: #

Add the following to your pubspec.yaml file:

dependencies:
  flutter_html: ^1.0.0-pre.1

Currently Supported HTML Tags: #

a, abbr, acronym, address, article, aside, b, bdi, bdo, big, blockquote, body, br, caption, cite, code, data, dd, del, dfn, div, dl, dt, em, figcaption, figure, footer, h1, h2, h3, h4, h5, h6, header, hr, i, img, ins, kbd, li, main, mark, nav, noscript, ol, p, pre, q, rp, rt, ruby, s, samp, section, small, span, strike, strong, sub, sup, table, tbody, td, template, tfoot, th, thead, time, tr, tt, u, ul, var

Currently Supported CSS Attributes: #

Coming soon!

Elements with planned support: #

See the development roadmap for the list of elements and css attributes I plan on supporting.

Why this package? #

This package is designed with simplicity in mind. Originally created to allow basic rendering of HTML content into the Flutter widget tree, this project has expanded to include support for basic CSS styling (both inline and in the <style> tag).

Example Usage: #

(For a much more extensive example, look at example/main.dart).

    Widget html = Html(
      data: """
        <div>
          <h1>Demo Page</h1>
          <p>This is a fantastic product that you should buy!</p>
          <h3>Features</h3>
          <ul>
            <li>It actually works</li>
            <li>It exists</li>
            <li>It doesn't cost much!</li>
          </ul>
          <!--You can pretty much put any html in here!-->
        </div>
      """,
      //Optional parameters:
      backgroundColor: Colors.white70,
      onLinkTap: (url) {
        // open url in a webview
      },
      style: {
        "div": Style(
          block: Block(
            margin: EdgeInsets.all(16),
            border: Border.all(width: 6),
            backgroundColor: Colors.grey,
          ),
          textStyle: TextStyle(
            color: Colors.red,
          ),
        ),
      },
      onImageTap: (src) {
        // Display the image in large form.
      },
    );

[1.0.0-pre.1]

  • 此包拷贝flutter_html 尝试使用开发版本

[1.0.0] - UNRELEASED

  • BREAKING: Requires Flutter version 1.7.3 or greater and Dart 2.2.2 or greater.
  • Adds support for a new parser, which resolves several major issues and adds several new features.
  • For a list of pre-release changes, including several BREAKING CHANGES, see the pre-release changelog

[0.11.0] - September 10, 2019:

  • Make it so width=100% doesn't throw error. Fixes #118.
  • You can now set width and/or height in ImageProperties to negative to ignore the width and/or height values from the html. Fixes #97
  • The img alt property now renders correctly when the image fails to load and with the correct style. Fixes #96
  • Add partial support for sub tag.
  • Add new option: shrinkToFit (#148). Fixes #75.

[0.10.4] - June 22, 2019:

  • Add support for customTextStyle to block and specialty HTML elements.

[0.10.3] - June 20, 2019:

  • Add src to the onImageTap callback (#93)

[0.10.2] - June 19, 2019:

  • Add customTextAlign property (#112)
  • Use tryParse instead of parse for image width and height attributes so that % values are ignored safely. Fixes #98

[0.10.1] - May 20, 2019:

  • Image properties and onImageTap for the richTextParser, plus some fixes (#90)
  • Hotfix 1 (June 6, 2019): Fixes #100

[0.10.0] - May 18, 2019:

  • BREAKING: useRichText now defaults to true
  • Support for aside, bdi, big, cite, data, ins, kbd, mark, nav, noscript, q, rp, rt, ruby, s, samp, strike, template, time, tt, and var added to RichText parser.

[0.9.9] - May 17, 2019:

  • Fixes extra padding issue (#87)

[0.9.8] - May 14, 2019:

  • Add support for address tag in RichText parser.

[0.9.7] - May 13, 2019:

  • Added onImageError callback
  • Added custom textstyle and edgeinsets callback (#72)
  • Update dependency versions (#84)
  • Fixes #82 and #86

[0.9.6] - March 11, 2019:

  • Fix whitespace issue. (#59)

[0.9.5] - March 11, 2019:

  • Add support for span in RichText parser. (#61)
  • Adds linkStyle attribute. (#70)
  • Adds tests for header, hr, and i (#62)

[0.9.4] - February 5, 2019:

  • Fixes table error in RichText parser. (#58)

[0.9.3] - January 31, 2019:

  • Adds support for base64 encoded images

[0.9.2] - January 31, 2019:

  • Adds partial support for deprecated font tag.

[0.9.1] - January 31, 2019:

  • Adds full support for sub and sup. (#46)
  • Fixes weak warning caught by Pub analysis (#54)

[0.9.0] - January 31, 2019:

  • Adds an alternate RichText parser and useRichText parameter. (#37)

[0.8.2] - November 1, 2018:

  • Removes debug prints.

[0.8.1] - October 19, 2018:

  • Adds typedef for onLinkTap function.

[0.8.0] - October 18, 2018:

  • Adds custom tag callback
  • Logging no longer shows up in production.

[0.7.1] - September 11, 2018:

  • Fixes issue with text nodes that contain only a space. (#24)
  • Fixes typo in README.md from 0.7.0.

[0.7.0] - September 10, 2018:

  • Adds full support for ul and ol

[0.6.2] - September 5, 2018:

  • Adds check for img src before trying to load it.
  • Adds support for img alt attribute.

[0.6.1] - September 4, 2018:

  • Fixed minor typo

[0.6.0] - September 4, 2018:

  • Update README.md and example
  • GitHub version 0.6.0 milestone reached

[0.5.6] - September 4, 2018:

  • Adds partial support for center and a renderNewlines property on the Html widget.

[0.5.5] - September 4, 2018:

  • Adds support for acronym, and big.

[0.5.4] - August 31, 2018:

  • Adds onLinkTap callback.

[0.5.3] - August 25, 2018:

  • Adds support for strike, and tt.

[0.5.2] - August 25, 2018:

  • Adds support for bdi and bdo

[0.5.1] - August 25, 2018:

  • Fixed issue with table rows not lining up correctly (#4)

[0.5.0] - August 23, 2018:

  • Major refactor that makes entire tree a Widget and eliminates the need to distinguish between inline and block elements.
  • Fixed #7, #9, #10, and #11.

[0.4.1] - August 15, 2018:

  • Fixed issue with images not loading when inside of p tag (#6)

[0.4.0] - August 15, 2018:

  • Adds support for table, tbody, tfoot, thead, tr, td, th, and caption

[0.3.1] - August 15, 2018:

  • Fixed issue where p was not rendered with the defaultTextStyle.

[0.3.0] - August 15, 2018:

  • Adds support for abbr, address, article, aside, blockquote, br, cite, code, data, dd, del, dfn, dl, dt, figcaption, figure, footer, header, hr, img, ins, kbd, li, main, mark, nav, noscript, pre, q, rp, rt, ruby, s, samp, section, small, span, template, time, and var

  • Adds partial support for a, ol, and ul

[0.2.0] - August 14, 2018:

  • Adds support for img.

[0.1.1] - August 14, 2018:

  • Fixed b to be bold, not italic...
  • Adds support for em, and strong
  • Adds support for a default TextStyle

[0.1.0] - August 14, 2018:

  • Renamed widget from HtmlWidget to Html
  • Adds support for p, h1, h2, h3, h4, h5, and h6.

[0.0.1] - August 14, 2018:

  • Adds support for body, div, b, i, and u.

example/README.md

example #

A new Flutter project.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

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


dependencies:
  use_html_t: ^1.0.0-pre.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:use_html_t/flutter_html.dart';
import 'package:use_html_t/html_parser.dart';
import 'package:use_html_t/image_properties.dart';
import 'package:use_html_t/rich_text_parser.dart';
import 'package:use_html_t/style.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
38
Health:
Code health derived from static analysis. [more]
93
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
85
Overall:
Weighted score of the above. [more]
64
Learn more about scoring.

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

  • Dart: 2.6.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Health suggestions

Fix lib/flutter_html.dart. (-5.84 points)

Analysis of lib/flutter_html.dart reported 12 hints, including:

line 14 col 22: 'padding' is deprecated and shouldn't be used.

line 15 col 22: 'backgroundColor' is deprecated and shouldn't be used.

line 16 col 22: 'defaultTextStyle' is deprecated and shouldn't be used.

line 18 col 22: 'renderNewlines' is deprecated and shouldn't be used.

line 21 col 22: 'customEdgeInsets' is deprecated and shouldn't be used.

Fix lib/src/layout_element.dart. (-0.50 points)

Analysis of lib/src/layout_element.dart reported 1 hint:

line 43 col 3: This function has a return type of 'TableRow', but doesn't end with a return statement.

Fix lib/src/styled_element.dart. (-0.50 points)

Analysis of lib/src/styled_element.dart reported 1 hint:

line 5 col 8: Don't import implementation files from another package.

Format lib/src/html_elements.dart.

Run flutter format to format lib/src/html_elements.dart.

Format lib/src/utils.dart.

Run flutter format to format lib/src/utils.dart.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (flutter_svg).

Package is pre-release. (-5 points)

Pre-release versions should be used with caution; their API can change in breaking ways.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
chewie ^0.9.8 0.9.8+1
chewie_audio ^1.0.0+1 1.0.0+1
css_colors ^1.0.2 1.0.2
csslib ^0.16.1 0.16.1
flutter 0.0.0
flutter_svg ^0.14.1 0.14.4 0.15.0
html ^0.14.0+2 0.14.0+3
video_player ^0.10.2+1 0.10.4+1 0.10.5
webview_flutter ^0.3.14+1 0.3.17 0.3.18+1
Transitive dependencies
charcode 1.1.2
collection 1.14.11 1.14.12
convert 2.1.1
meta 1.1.7 1.1.8
open_iconic_flutter 0.3.0
path 1.6.4
path_drawing 0.4.1
path_parsing 0.1.4
petitparser 2.4.0
screen 0.0.5
sky_engine 0.0.99
source_span 1.5.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
video_player_platform_interface 1.0.3 1.0.4
xml 3.5.0 3.6.1
Dev dependencies
flutter_test