flutter_super_html_viewer 0.0.1 copy "flutter_super_html_viewer: ^0.0.1" to clipboard
flutter_super_html_viewer: ^0.0.1 copied to clipboard

A Flutter plugin that provides a HtmlViewer widget on multiple platforms

example/lib/main.dart

import 'dart:developer';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_super_html_viewer/view/mobile/mobile_html_content_viewer.dart';
import 'package:flutter_super_html_viewer/view/web/web_html_content_viewer.dart';
import 'package:flutter_super_html_viewer/view/web/web_html_content_viewer_controller.dart';

void main() {
  runApp(const MyApp());
}

const _htmlContent =
'''<p>Here is some text</p> with a <a href="https://github.com/dab246/flutter_super_webview">link</a>.
  <p>Here is <b>bold</b> text</p>
  <p>Here is <i>some italic sic</i> text</p>
  <p>Here is <i><b>bold and italic</b></i> text</p>
  <p style="text-align: center;">Here is <u><i><b>bold and italic and underline</b></i></u> text</p>
  <ul><li>one list element</li><li>another point</li></ul>
  <blockquote>Here is a quote<br/>
    that spans several lines<br/>
    <blockquote>
        Another second level blockqote 
    </blockquote>
</blockquote>
''';

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'WebView Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'WebView Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      backgroundColor: Colors.white,
      body: SingleChildScrollView(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            if (kIsWeb)
              WebHtmlContentViewer(
                widthContent: MediaQuery.of(context).size.width,
                heightContent: MediaQuery.of(context).size.height,
                contentHtml: _htmlContent,
                controller: WebHtmlContentViewerController(),
                mailtoDelegate: (uri) {
                  log('_MyHomePageState::build():mailtoDelegate: $uri');
                }
              )
            else
              MobileHtmlContentViewer(
                contentHtml: _htmlContent,
                heightContent: MediaQuery.of(context).size.height,
                mailtoDelegate: (uri) async {
                  log('_MyHomePageState::build():mailtoDelegate: $uri');
                },
                onScrollHorizontalEnd: (leftDirection) {
                  log('_MyHomePageState::build():onScrollHorizontalEnd: $leftDirection');
                },
                onWebViewLoaded: (isScrollPageViewActivated) {
                  log('_MyHomePageState::build():onWebViewLoaded: $isScrollPageViewActivated');
                },
              )
          ],
        ),
      )// This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
17
likes
0
pub points
92%
popularity

Publisher

unverified uploader

A Flutter plugin that provides a HtmlViewer widget on multiple platforms

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cupertino_icons, flutter, universal_html, url_launcher, webview_flutter

More

Packages that depend on flutter_super_html_viewer