This widget turn html string into flutter widgets like Text, RichText and Table.
This is so not a webview alternative. Think this as a read mode for simple html elements.
The widget is extracted from wiki-flutter, and is initially designed for html segments in the mobile version of wikipedia articles only, so there's gonna be many, many issues for arbitrary html segments.
import 'package:flutter_html_widget/flutter_html_widget.dart'; final html = """ <section class="homepage__key_points card"> <h1 class="homepage__title"> Build beautiful native apps in record time </h1> <div class="homepage__tagline"> Flutter is Google’s mobile app SDK for crafting high-quality native interfaces on iOS and Android in record time. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source. </div> </section> """; new MaterialApp( home: new Material( child: new HtmlWidget(html: html, key: key) ), );
will produce widgets like
new Wrap( children: <Widget>[ new Container( padding: EdgeInsets.all(8.0), child: new RichText( text: new TextSpan( children: [ new TextSpan(text: "Build beautiful native apps in record time") ] ), ) ) ], )
Add this to your package's pubspec.yaml file:
dependencies: flutter_html_widget: ^0.0.1
You can install packages from the command line:
$ pub get
$ flutter pub get
Alternatively, your editor might support
pub get or
flutter pub get.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
|0.0.2||Aug 14, 2018|
|0.0.1||May 21, 2018|
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.
Support Dart 2 in
The SDK constraint in
pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.
dartdoc successfully runs on your package's source files. (-10 points)
Dependencies were not resolved.
|Dart SDK||>=2.0.0 <=3.0.0|