f_web_view 0.0.4 copy "f_web_view: ^0.0.4" to clipboard
f_web_view: ^0.0.4 copied to clipboard

A new Flutter web view plugin.

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:f_web_view/f_web_view.dart';

void main() {
  runApp(MyApp());
  if(Platform.isAndroid) {
    SystemUiOverlayStyle systemUiOverlayStyle =
    SystemUiOverlayStyle(statusBarColor: Colors.transparent);
    SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  }
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    // initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await FWebView.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  String _title = "Plugin example app";
  String _tag = "FWebView example main";

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text(_title),
        ),
        body: Center(
          child: Column(
            children: [
              Text("platformVersion $_platformVersion"),
              Expanded(
                child: FWebView(
                  url: "https://www.bing.com",
                  enableJavaScript: true,
                  viewCreateCallBack: (result, id) {
                    setState(() {
                      initPlatformState();
                    });
                  },
                  onReceivedTitle: (title) {
                    setState(() {
                      _title = title;
                    });
                  },
                  onPageStarted: (url) {
                    print("$_tag onPageStarted $url");
                  },
                  onProgressChanged: (progress) {
                    print("$_tag onProgressChanged $progress");
                  },
                  onPageFinished: (url) {
                    print("$_tag onPageFinished $url");
                  },
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
25
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter web view plugin.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on f_web_view