All Projects → shah-xad → webview_flutter_plus

shah-xad / webview_flutter_plus

Licence: other
An extension of webview_flutter to load HTML,CSS and Javascript even from Assets or Strings.

Programming Languages

dart
5743 projects
HTML
75241 projects
swift
15916 projects
javascript
184084 projects - #8 most used programming language
kotlin
9241 projects
CSS
56736 projects
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to webview flutter plus

webview
Cross-platform header-only webview library for C++
Stars: ✭ 59 (+31.11%)
Mutual labels:  webview
vscode-android-webview-debug
Debug your JavaScript code running in WebViews on any Android device from VS Code.
Stars: ✭ 18 (-60%)
Mutual labels:  webview
MkBrowser
🌐 一个简易的 Android 网页浏览器 A simple Android web browser
Stars: ✭ 55 (+22.22%)
Mutual labels:  webview
tesla auth
Securely generate API tokens for third-party access to your Tesla.
Stars: ✭ 114 (+153.33%)
Mutual labels:  webview
gowebview
tool to build android apps with WebView from your golang http server; moved to gitlab.com/microo8/gowebview
Stars: ✭ 35 (-22.22%)
Mutual labels:  webview
cordova-plugin-x5-tbs
Use Tencent Browser Service(TBS) instead of System WebView for Cordova App
Stars: ✭ 65 (+44.44%)
Mutual labels:  webview
X5Bridge
Three party libraries of Tencent x5webview and JS interaction
Stars: ✭ 17 (-62.22%)
Mutual labels:  webview
topframe
Local webpage screen overlay for customizing your computing experience
Stars: ✭ 321 (+613.33%)
Mutual labels:  webview
flutter app o2o
flutter高校食堂o2o预定服务,商业级应用,持续升级,完全开源。
Stars: ✭ 45 (+0%)
Mutual labels:  webview
VHLWebView
微信/支付宝样式的网络浏览器控件。WKwebview 封装,js bridge和拦截url方式两种方法实现 oc和js交互
Stars: ✭ 14 (-68.89%)
Mutual labels:  webview
flutter webview
A complete tutorial series on Flutter webview.
Stars: ✭ 39 (-13.33%)
Mutual labels:  webview
QuickWebKit
A great & strong plugin based WebViewController. 一款基于插件的 WebView 视图控制器,您可以基于它设计您的浏览器插件,然后像积木一样来组装它们。
Stars: ✭ 29 (-35.56%)
Mutual labels:  webview
RobustWebView
Android WebView H5 秒开方案总结
Stars: ✭ 38 (-15.56%)
Mutual labels:  webview
Android-Web-Inspector
How to Inspecting Android WebView, Network logs, XHR logs (including url request and parameter) and Element/DOM inspecting
Stars: ✭ 54 (+20%)
Mutual labels:  webview
autojs-webView
autojs的webView实现,支持初始化脚本注入、jsBridge两端互调
Stars: ✭ 38 (-15.56%)
Mutual labels:  webview
webview
Build cross platform desktop apps with Elixir and web technologies.
Stars: ✭ 18 (-60%)
Mutual labels:  webview
ux-lab
No description or website provided.
Stars: ✭ 49 (+8.89%)
Mutual labels:  webview
react-native-fblogin
📦 A React Native 'Facebook Login' component without wrapping any Facebook Native/Web SDK
Stars: ✭ 19 (-57.78%)
Mutual labels:  webview
webview-cs
C# Bindings to https://github.com/zserge/webview
Stars: ✭ 110 (+144.44%)
Mutual labels:  webview
flutter examples
Random flutter examples
Stars: ✭ 18 (-60%)
Mutual labels:  webview

webview_flutter_plus

Contents

About

webview_flutter_plus is a powerful extension of webview_flutter. This package helps to load Local HTML, CSS and Javascript content from Assets or Strings. This inherits all features of webview_flutter with minor API changes.

Do check flutter_tex a powerful implementation of this package.

What's unique in webview_flutter_plus

  • Load HTML, CSS and Javascript content from Assets, see example.
  • Load HTML, CSS and Javascript content from Strings, see example.
  • Get height of Web content which will allow you to use WebviewPlus widget even in list view, see example.
  • It includes all features of its parent plugin webview_flutter.

How to use?

1: Add this to your package's pubspec.yaml file:

dependencies:
  webview_flutter_plus: ^0.3.0

2: You can install packages from the command line:

$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3: Now you need to put the following implementations in Android and iOS respectively.

Android

Make sure to add this line android:usesCleartextTraffic="true" in your <project-directory>/android/app/src/main/AndroidManifest.xml under application like this.

<application
       android:usesCleartextTraffic="true">
</application>

Required Permissions are:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

iOS

Add following code in your <project-directory>/ios/Runner/Info.plist

<key>NSAppTransportSecurity</key>
  <dict>
    <key>NSAllowsArbitraryLoads</key> <true/>
  </dict>
<key>io.flutter.embedded_views_preview</key> <true/> 

4: Now in your Dart code, you can use:

import 'package:webview_flutter_plus/webview_flutter_plus.dart'; 

5: Now you can use WebViewPlus as a widget:

Examples

Loading From String

WebViewPlus(
    javascriptMode: JavascriptMode.unrestricted,
    onWebViewCreated: (controller) {
      controller.loadString(r"""
           <html lang="en">
            <body>hello world</body>
           </html>
      """);
    },
  )

Loading from Assets

It is mandatory to mention all associated HTML, CSS and Javascript files in pubspecs.yaml under assets:

WebViewPlus(
    javascriptMode: JavascriptMode.unrestricted,
    onWebViewCreated: (controller) {
      controller.loadUrl('assets/index.html');
    },
  )

Use in ListView

WebViewPlusController also allows you to get WebViewPlus height like controller.getHeight()

WebViewPlusController _controller;
double _height = 1;

@override
Widget build(BuildContext context) {
return Scaffold(
  appBar: AppBar(
    title: Text('ListView Example'),
  ),
  body: ListView(
    children: [
      SizedBox(
        height: _height,
        child: WebViewPlus(
          onWebViewCreated: (controller) {
            this._controller = controller;
            controller.loadUrl('assets/index.html');
          },
          onPageFinished: (url) {
            _controller.getHeight().then((double height) {
              print("Height:  " + height.toString());
              setState(() {
                _height = height;
              });
            });
          },
          javascriptMode: JavascriptMode.unrestricted,
        ),
      )
    ],
  ),
);
}

Plus APIs

WebViewPlusController controller;

  • controller.loadUrl('path/to/index.html') load HTML content from Assets.
  • controller.loadString(r"<html>HTML, CSS and Javascript code in raw string</html>"); load HTML, CSS and Javascript Code from a String.
  • controller.getHeight() returns height of WebViewPlus.

API differences from webview_flutter

There are very minor API differences as following.

webview_flutter webview_flutter_plus
WebView WebViewPlus
WebViewController WebViewPlusController contains WebViewController inside.
WebViewCreatedCallback WebViewPlusCreatedCallback

Rest everything is same as webview_flutter.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].