webview_flutter_plus 0.4.2 copy "webview_flutter_plus: ^0.4.2" to clipboard
webview_flutter_plus: ^0.4.2 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.closeServer();
    super.dispose();
  }
}
151
likes
0
pub points
97%
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