webview_flutter_plus 0.4.3 copy "webview_flutter_plus: ^0.4.3" to clipboard
webview_flutter_plus: ^0.4.3 copied to clipboard

An extension of webview_flutter to load local HTML,CSS and Javascript from Assets or Strings and much more.

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:webview_flutter_plus/webview_flutter_plus.dart';

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

class WebViewPlusExample extends StatelessWidget {
  const WebViewPlusExample({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MainPage(),
    );
  }
}

class MainPage extends StatefulWidget {
  const MainPage({super.key});

  @override
  State<MainPage> createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
  late WebViewControllerPlus _controler;

  @override
  void initState() {
    _controler = WebViewControllerPlus()
      ..setJavaScriptMode(JavaScriptMode.unrestricted)
      ..setBackgroundColor(const Color(0x00000000))
      ..setNavigationDelegate(
        NavigationDelegate(
          onPageFinished: (String url) {
            // Get height of WebviewPlus
            _controler.getWebViewHeight().then((value) {
              var height = int.parse(value.toString()).toDouble();
              if (height != _height) {
                if (kDebugMode) {
                  print("Height is: $value");
                }
                setState(() {
                  _height = height;
                });
              }
            });
          },
        ),
      )
      ..loadAssetServer('assets/index.html');
    super.initState();
  }

  double _height = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('webview_flutter_plus Example'),
        ),
        body: ListView(
          children: [
            Text("Height of WebviewPlus: $_height",
                style: const TextStyle(fontWeight: FontWeight.bold)),
            SizedBox(
              height: _height,
              child: WebViewWidget(
                controller: _controler,
              ),
            ),
            const Text("End of WebviewPlus",
                style: TextStyle(fontWeight: FontWeight.bold)),
          ],
        ));
  }

  @override
  void dispose() {
    _controler.server.close();
    super.dispose();
  }
}
143
likes
0
pub points
96%
popularity

Publisher

verified publishershahxad.com

An extension of webview_flutter to load local HTML,CSS and Javascript from Assets or Strings and much more.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, mime, webview_flutter

More

Packages that depend on webview_flutter_plus