Coder Social home page Coder Social logo

fluttercommunity / flutter_webview_plugin Goto Github PK

View Code? Open in Web Editor NEW
1.5K 44.0 930.0 7.33 MB

Community WebView Plugin - Allows Flutter to communicate with a native WebView.

Home Page: https://pub.dev/packages/flutter_webview_plugin

License: Other

Java 38.93% Ruby 1.65% Objective-C 26.08% Dart 32.11% Shell 1.23%
hacktoberfest

flutter_webview_plugin's Introduction

Flutter Community: flutter_webview_plugin

NOTICE

We are working closely with the Flutter Team to integrate all the Community Plugin features in the Official WebView Plugin. We will try our best to resolve PRs and Bugfixes, but our priority right now is to merge our two code-bases. Once the merge is complete we will deprecate the Community Plugin in favor of the Official one.

Thank you for all your support, hopefully you'll also show it for Official Plugin too.

Keep Fluttering!

Flutter WebView Plugin

pub package

Plugin that allows Flutter to communicate with a native WebView.

Warning: The webview is not integrated in the widget tree, it is a native view on top of the flutter view. You won't be able see snackbars, dialogs, or other flutter widgets that would overlap with the region of the screen taken up by the webview.

The getSafeAcceptedType() function is available only for minimum SDK of 21. eval() function only supports SDK of 19 or greater for evaluating Javascript.

Getting Started

For help getting started with Flutter, view our online documentation.

iOS

In order for plugin to work correctly, you need to add new key to ios/Runner/Info.plist

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
</dict>

NSAllowsArbitraryLoadsInWebContent is for iOS 10+ and NSAllowsArbitraryLoads for iOS 9.

How it works

Launch WebView Fullscreen with Flutter navigation

new MaterialApp(
      routes: {
        "/": (_) => new WebviewScaffold(
          url: "https://www.google.com",
          appBar: new AppBar(
            title: new Text("Widget webview"),
          ),
        ),
      },
    );

Optional parameters hidden and initialChild are available so that you can show something else while waiting for the page to load. If you set hidden to true it will show a default CircularProgressIndicator. If you additionally specify a Widget for initialChild you can have it display whatever you like till page-load.

e.g. The following will show a read screen with the text 'waiting.....'.

return new MaterialApp(
  title: 'Flutter WebView Demo',
  theme: new ThemeData(
    primarySwatch: Colors.blue,
  ),
  routes: {
    '/': (_) => const MyHomePage(title: 'Flutter WebView Demo'),
    '/widget': (_) => new WebviewScaffold(
      url: selectedUrl,
      appBar: new AppBar(
        title: const Text('Widget webview'),
      ),
      withZoom: true,
      withLocalStorage: true,
      hidden: true,
      initialChild: Container(
        color: Colors.redAccent,
        child: const Center(
          child: Text('Waiting.....'),
        ),
      ),
    ),
  },
);

FlutterWebviewPlugin provide a singleton instance linked to one unique webview, so you can take control of the webview from anywhere in the app

listen for events

final flutterWebviewPlugin = new FlutterWebviewPlugin();

flutterWebviewPlugin.onUrlChanged.listen((String url) {

});

Listen for scroll event in webview

final flutterWebviewPlugin = new FlutterWebviewPlugin();
flutterWebviewPlugin.onScrollYChanged.listen((double offsetY) { // latest offset value in vertical scroll
  // compare vertical scroll changes here with old value
});

flutterWebviewPlugin.onScrollXChanged.listen((double offsetX) { // latest offset value in horizontal scroll
  // compare horizontal scroll changes here with old value
});

Note: Do note there is a slight difference is scroll distance between ios and android. Android scroll value difference tends to be larger than ios devices.

Hidden WebView

final flutterWebviewPlugin = new FlutterWebviewPlugin();

flutterWebviewPlugin.launch(url, hidden: true);

Close launched WebView

flutterWebviewPlugin.close();

Webview inside custom Rectangle

final flutterWebviewPlugin = new FlutterWebviewPlugin();

flutterWebviewPlugin.launch(url,
  fullScreen: false,
  rect: new Rect.fromLTWH(
    0.0,
    0.0,
    MediaQuery.of(context).size.width,
    300.0,
  ),
);

Injecting custom code into the webview

Use flutterWebviewPlugin.evalJavaScript(String code). This function must be run after the page has finished loading (i.e. listen to onStateChanged for events where state is finishLoad).

If you have a large amount of JavaScript to embed, use an asset file. Add the asset file to pubspec.yaml, then call the function like:

Future<String> loadJS(String name) async {
  var givenJS = rootBundle.loadString('assets/$name.js');
  return givenJS.then((String js) {
    flutterWebViewPlugin.onStateChanged.listen((viewState) async {
      if (viewState.type == WebViewState.finishLoad) {
        flutterWebViewPlugin.evalJavascript(js);
      }
    });
  });
}

Accessing local files in the file system

Set the withLocalUrl option to true in the launch function or in the Webview scaffold to enable support for local URLs.

Note that, on iOS, the localUrlScope option also needs to be set to a path to a directory. All files inside this folder (or subfolder) will be allowed access. If ommited, only the local file being opened will have access allowed, resulting in no subresources being loaded. This option is ignored on Android.

Ignoring SSL Errors

Set the ignoreSSLErrors option to true to display content from servers with certificates usually not trusted by the Webview like self-signed certificates.

Warning: Don't use this in production.

Note that on iOS, you need to add new key to ios/Runner/Info.plist

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
</dict>

NSAllowsArbitraryLoadsInWebContent is for iOS 10+ and NSAllowsArbitraryLoads for iOS 9. Otherwise you'll still not be able to display content from pages with untrusted certificates.

You can test your ignorance if ssl certificates is working e.g. through https://self-signed.badssl.com/

Webview Events

  • Stream<Null> onDestroy
  • Stream<String> onUrlChanged
  • Stream<WebViewStateChanged> onStateChanged
  • Stream<double> onScrollXChanged
  • Stream<double> onScrollYChanged
  • Stream<String> onError

Don't forget to dispose webview flutterWebviewPlugin.dispose()

Webview Functions

Future<Null> launch(String url, {
    Map<String, String> headers: null,
    Set<JavascriptChannel> javascriptChannels: null,
    bool withJavascript: true,
    bool clearCache: false,
    bool clearCookies: false,
    bool hidden: false,
    bool enableAppScheme: true,
    Rect rect: null,
    String userAgent: null,
    bool withZoom: false,
    bool displayZoomControls: false,
    bool withLocalStorage: true,
    bool withLocalUrl: true,
    String localUrlScope: null,
    bool withOverviewMode: false,
    bool scrollBar: true,
    bool supportMultipleWindows: false,
    bool appCacheEnabled: false,
    bool allowFileURLs: false,
    bool useWideViewPort: false,
    String invalidUrlRegex: null,
    bool geolocationEnabled: false,
    bool debuggingEnabled: false,
    bool ignoreSSLErrors: false,
});
Future<String> evalJavascript(String code);
Future<Map<String, dynamic>> getCookies();
Future<Null> cleanCookies();
Future<Null> resize(Rect rect);
Future<Null> show();
Future<Null> hide();
Future<Null> reloadUrl(String url);
Future<Null> close();
Future<Null> reload();
Future<Null> goBack();
Future<Null> goForward();
Future<Null> stopLoading();
Future<bool> canGoBack();
Future<bool> canGoForward();

flutter_webview_plugin's People

Contributors

charafau avatar ciceroduarte avatar cvolzke4 avatar dinhha avatar gadfly361 avatar ghigh avatar hnvn avatar howardt12345 avatar islxyqwe avatar jeroen-meijer avatar jngbng avatar jordansilva avatar js1972 avatar kpedia avatar lakexyde avatar lejard-h avatar lidongze91 avatar long1eu avatar lucianoiam avatar pedia avatar rafern avatar readytopark avatar romkor avatar rydein avatar sethladd avatar slightfoot avatar sroddy avatar theblackcat102 avatar themisir avatar ypelud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutter_webview_plugin's Issues

Navigation drawer

Is it possible to add a navigation drawer widget ? The readme suggests that this is not possible but want to get an opinion on this.

The reason being that the navigation drawer is much smoother

Does not support Chinese

English is normal, I got an error when I entered Chinese

english

new WebviewScaffold(
        url: new Uri.dataFromString(
                '<html><body>hello</body></html>',
                mimeType: 'text/html')
            .toString())

chinese

new WebviewScaffold(
        url: new Uri.dataFromString(
                '<html><body>你好</body></html>',
                mimeType: 'text/html')
            .toString())

Hope to get a reply

thanks

<Summarize your issues here>

From @GokulDharumar on March 12, 2018 19:28

URL: https://pub.dartlang.org/packages/flutter_webview_plugin
when i use PopupmenuButton with webviewscafold. the menus are not displayed on top of webview ... the webview kind of hides the menu

routes: {
"/": () => new MyHomePage(title: "Flutter WebView Demo"),
"/widget": (
) => new WebviewScaffold(
url: selectedUrl,
appBar: new AppBar(
title: new Text("Test"),

        actions: <Widget>[
          new PopupMenuButton<Choice>( // overflow menu
            onSelected: _select,
            itemBuilder: (BuildContext context) {
              return choices.skip(0).map((Choice choice) {
                return new PopupMenuItem<Choice>(
                  value: choice,
                  child: new Icon(choice.icon),
                );
              }).toList();
            },
          ),


        ],
      ),

    )
  },

Copied from original issue: dart-lang/pub-dev#1095

WebviewScaffold with a drawer

Hi,
Is there a way to use a WebviewScaffold with a drawer?

I revised WebviewScaffold like this.

class MyWebviewScaffold extends StatefulWidget {
  final PreferredSizeWidget appBar;
  final String url;
  final bool withJavascript;
  final bool clearCache;
  final bool clearCookies;
  final bool enableAppScheme;
  final String userAgent;
  final bool primary;
  final List<Widget> persistentFooterButtons;
  final Widget bottomNavigationBar;
  final bool withZoom;
  final Drawer drawer;

  MyWebviewScaffold(
      {Key key,
      this.appBar,
      @required this.url,
      this.withJavascript,
      this.clearCache,
      this.clearCookies,
      this.enableAppScheme,
      this.userAgent,
      this.primary: true,
      this.persistentFooterButtons,
      this.bottomNavigationBar,
      this.withZoom,
      this.drawer})
...
class _MyWebviewScaffoldState extends State<MyWebviewScaffold> {
...
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: widget.appBar,
      persistentFooterButtons: widget.persistentFooterButtons,
      bottomNavigationBar: widget.bottomNavigationBar,
      body: new Center(child: new CircularProgressIndicator()),
      drawer: widget.drawer,
    );
  }

When I tab a drawer button, the drawer appears behind the webview.
I set the elevation of the drawer as 10000, but it's not working.
I think this is related to the Rect class of the Dart UI package.
Is there another way to use a webview with a drawer?

2018-03-16 1

Failed to build iOS app - 'flutter_webview_plugin/FlutterWebviewPlugin.h' file not found

Hi, I've recently integrated this plugin into my working Flutter project and attempted to build a preview for Android (which seems to work fine), and iOS which returned an error of the following:

Error output from Xcode build:

** BUILD FAILED **

Xcode's output:

=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
/flutterprojects/myapp/ios/Runner/GeneratedPluginRegistrant.m:6:9: fatal error: 'flutter_webview_plugin/FlutterWebviewPlugin.h' file not found
#import <flutter_webview_plugin/FlutterWebviewPlugin.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

I could use some advice to know if the error I am seeing is by design on my part.

Launching with `rect` causes an exception

This code works:
flutterWebviewPlugin.launch("https://google.com");

This code, however,

flutterWebviewPlugin.launch("https://google.com",
        rect: new Rect.fromLTRB(0.0, 0.0, 0.0, 0.0));

causes an exception. I tried with different rect settings, tried putting this code in different places - in initState(), in build(), in main.dart - with the same results:

E/flutter (27126): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (27126): PlatformException(error, The specified child already has a parent. You must call removeView() on the child's parent first., null)
E/flutter (27126): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:547:7)
E/flutter (27126): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:279:18)
E/flutter (27126): <asynchronous suspension>
E/flutter (27126): #2      FlutterWebviewPlugin.launch (package:flutter_webview_plugin/src/base.dart:103:20)
E/flutter (27126): <asynchronous suspension>
E/flutter (27126): #3      _AboutViewState.build (package:rebelation/screens/about_view/about_view.dart:48:33)
E/flutter (27126): #4      StatefulElement.build (package:flutter/src/widgets/framework.dart:3713:27)
E/flutter (27126): #5      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3625:15)
E/flutter (27126): #6      Element.rebuild (package:flutter/src/widgets/framework.dart:3478:5)
E/flutter (27126): #7      StatefulElement.update (package:flutter/src/widgets/framework.dart:3782:5)
E/flutter (27126): #8      Element.updateChild (package:flutter/src/widgets/framework.dart:2682:15)
E/flutter (27126): #9      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636:16)
E/flutter (27126): #10     Element.rebuild (package:flutter/src/widgets/framework.dart:3478:5)
E/flutter (27126): #11     StatelessElement.update (package:flutter/src/widgets/framework.dart:3685:5)
E/flutter (27126): #12     Element.updateChild (package:flutter/src/widgets/framework.dart:2682:15)
E/flutter (27126): #13     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4644:14)
E/flutter (27126): #14     Element.updateChild (package:flutter/src/widgets/framework.dart:2682:15)
E/flutter (27126): #15     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4644:14)
E/flutter (27126): #16     Element.updateChild (package:flutter/src/widgets/framework.dart:2682:15)
E/flutter (27126): #17     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4644:14)
E/flutter (27126): #18     Element.updateChild (package:flutter/src/widgets/framework.dart:2682:15)
E/flutter (27126): #19     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4644:14)
E/flutter (27126): #20     Element.updateChild (package:flutter/src/widgets/framework.dart:2682:15)
E/flutter (27126): #21     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636:16)
E/flutter (27126): #22     Element.rebuild (package:flutter/src/widgets/framework.dart:3478:5)
E/flutter (27126): #23     StatefulElement.update (package:flutter/src/widgets/framework.dart:3782:5)
E/flutter (27126): #24     Element.updateChild (package:flutter/src/widgets/framework.dart:2682:15)
E/flutter (27126): #25     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636:16)
E/flutter (27126): #26     Element.rebuild (package:flutter/src/widgets/framework.dart:3478:5)
E/flutter (27126): #27     StatelessElement.update (package:flutter/src/widgets/framework.dart:3685:5)
E/flutter (27126): #28     Element.updateChild (package:flutter/src/widgets/framework.dart:2682:15)
E/flutter (27126): #29     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636:16)
E/flutter (27126): #30     Element.rebuild (package:flutter/src/widgets/framework.dart:3478:5)
E/flutter (27126): #31     StatefulElement.update (package:flutter/src/widgets/framework.dart:3782:5)
E/flutter (27126): #32     Element.updateChild (package:flutter/src/widgets/framework.dart:2682:15)
E/flutter (27126): #33     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4644:14)
E/flutter (27126): #34     Element.updateChild (package:flutter/src/widgets/framework.dart:2682:15)
E/flutter (27126): #35     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636:16)
E/flutter (27126): #36     Element.rebuild (package:flutter/src/widgets/framework.dart:3478:5)
E/flutter (27126): #37     ProxyElement.update (package:flutter/src/widgets/framework.dart:3892:5)
E/flutter (27126): #38     Element.updateChild (package:flutter/src/widgets/framework.dart:2682:15)
E/flutter (27126): #39     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4644:14)
E/flutter (27126): #40     Element.updateChild (package:flutter/src/widgets/framework.dart:2682:15)
E/flutter (27126): #41     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636:16)
E/flutter (27126): #42     Element.rebuild (package:flutter/src/widgets/framework.dart:3478:5)
E/flutter (27126): #43     StatefulElement.update (package:flutter/src/widgets/framework.dart:3782:5)
E/flutter (27126): #44     Element.

Notify when URL changes

Would it be possible to add a feature to know when the URL of the browser has changed?

Currently using Oauth2, if a http server is the redirect, some apps show a warning to the user that the credentials are being sent to an insecure server.

If https is used, then iOS throws an error loading the redirect url.

[Android] Back button doesn't go back a page but quits webview

On Android when navigating through websites I want to use the back button to go back a page. This is currently not possible, the webview will be closed. Is this intentional?

I use the example from the repository and can reproduce this behavior with the fullscreen and widget webview. I digged in the source code and it should be able to set the back button to go back in the webviews history first by setting a setOnKeyListener on the webview (see here).

How is the behaviour on iOS? If I recall correctly, you swipe from left to right to go back a page in Safari. Is this currently possible?

For the Android part I can create a pull request to change the back button behaviour. Should it be configurable or always go back until we reach the end of the history before exiting the webview?

no back button on iOS fullscreen

iOS does not provide a back button like Android
we should be able to add a back arrow with a top bar with title using launch function

flutterWebviewPlugin.launch(url, backButton: true, title: "Page tile in top bar");

Load a local file

Hi, how can I open a file that is locally stored on the device? For example, if the file index.html is located inside my project's assets folder?

Webview crashes on url change on iOS

I'm getting the following error while trying to use the webview on iOS (via the Simulator) which is crashing the app. It only seems to happen for some URLs. On Android everything works fine, but on iOS I'm able to get through the login prompt and oAuth acceptance pages, but then it crashes when it tries to navigate to the actual authenticated app.

Unsupported value: <FlutterError: 0x60800023b740> of type FlutterError
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010dff51e6 __exceptionPreprocess + 294
	1   libobjc.A.dylib                     0x000000010d68a031 objc_exception_throw + 48
	2   CoreFoundation                      0x000000010dffa472 +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x000000010d12d652 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
	4   Flutter                             0x000000010b89a808 -[FlutterStandardWriter writeValue:] + 2091
	5   Flutter                             0x000000010b89ae52 -[FlutterStandardMethodCodec encodeMethodCall:] + 136
	6   Flutter                             0x000000010b8945dc -[FlutterMethodChannel invokeMethod:arguments:] + 58
	7   flutter_webview_plugin              0x000000010d052b62 -[FlutterWebviewPlugin webView:didFailNav<…>
Lost connection to device.

MissingPluginException(No implementation found for method close on channel flutter_webview_plugin)

I am trying to have WebView in Flutter using WebviewScaffold widget.

I have installed flutter_webview_plugin: "^0.1.0+1"

but I am getting ERROR:
MissingPluginException(No implementation found for method close on channel flutter_webview_plugin)
.
.
.
MissingPluginException(No implementation found for method launch on channel flutter_webview_plugin)
.
.
.

Below is how my page looks like:

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


class BulkProductUpdatePageRoute extends MaterialPageRoute {
  BulkProductUpdatePageRoute():
      super(builder: (BuildContext context) => new BulkProductUpdatePage());
}

class BulkProductUpdatePage extends StatefulWidget {
  @override
  _BulkProductUpdatePageState createState() => new _BulkProductUpdatePageState();
}

class _BulkProductUpdatePageState extends State<BulkProductUpdatePage> {

  @override
  Widget build(BuildContext context) {
    return new WebviewScaffold(
      appBar: new AppBar(
        leading: new RetailAppBarLeading(),
        title: new Text('Bulk Product Update'),
        bottom: appBarBottom(
          child: new Container(
            child: new TextField(
              decoration: new InputDecoration(
                  icon: new Icon(
                    Icons.search,
                    color: Colors.grey,
                  ),
                  hideDivider: true,
                  hintText: 'Search Products'
              ),
            ),
            padding: new EdgeInsets.only(
                bottom: 5.0
            ),
          ),
        ),
      ),
      url: 'https://pub.dartlang.org/packages/flutter_webview_plugin#-installing-tab-',
    );
  }
}

Set AppBar in webview.launch(url)

You can't set the AppBar when using launch(url) and if you use the WebviewScaffold you can't access cookies, attach listeners, ...
Would it be possible to add the ability to specify the appbar when launching?
An API that is getting popular in the React community is the so called “render prop”. Would that be possible in dart?

flutterWebviewPlugin.launch(
  url,
  appBar: (state) => new AppBar(...),
);

new WebviewScaffold(
  url: "https://www.google.com",
  appBar: (state) => new AppBar(
    title: new Text(state.url),
  ),
)

state could hold things like url, host, isSecure but also functions like goBack(), close(), goTo(url). This would make it a lot easier to add functionality to the appbar buttons.

Update the LICENSE file

The default name "Your Company" which seems to have been used to fill out the template makes the actual wording of the license problematic.

Neither the name of Your Company nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

Using SFSafariViewController on iOS

Are there any plans to use SFSafariViewController instead of UIWebView? I've read here SFSafariViewController is necessary in apps using OAuth 2 authorization. I think iOS apps not using SFSafariViewController will be rejected in App Store.

I don't if there's something similar (a native web view showing the current url) in Android. I know I could show the url in the AppBar when using a WebviewScaffold, but it's not the same.

Thank you in advance for your response!

Remove the appbar???

When I launch webview in flutter, I don't need the appbar (back button and the title). How can I remove it?

image
Seem like this is the arguments for function "launch", but I can't use it as well..
Thanks you guys.

Navigation inside webview with atos payment system

First, thank you very much for this very nice plugin for flutter.

Next, i need your help because i am trying to implement payment system inside flutter_webview_plugin.

When i open the webview for example like this :

      // close any open browser (happen on hot reload)
      await flutterWebviewPlugin.close();
      _isOpen = true;

      // init server
      _server = await _createServer();
      _listenCode(_server);

      // catch onDestroy event of WebView
      flutterWebviewPlugin.onDestroy.first.then((_) {
        _close();
      });

      flutterWebviewPlugin.onBackPressed.first.then((_) {
        _close();
      });

      // launch url inside webview
      flutterWebviewPlugin.launch(url,
          clearCookies: !cookie, fullScreen: fullscreen);

It is working well and my user is redirect to flutter webview to my payment page.
But when i am on the payment page atos ask me to chose my credit card like this :

askcard

On the computer when i click on a card everything is working well and i am redirected to the next page but when i am inside the flutter webview nothing happened and the flutter console show :

D/AppTracker(13525): App Event: stop
I/zygote  (13525): Do partial code cache collection, code=123KB, data=113KB
I/zygote  (13525): After code cache collection, code=123KB, data=113KB
I/zygote  (13525): Increasing code cache capacity to 512KB
E/BoostFramework(13525): BoostFramework() : Exception_1 = java.lang.NoSuchMethodException: perfIOPrefetchStart [int, class java.lang.String]
E/BoostFramework(13525): BoostFramework() : Exception_1 = java.lang.NoSuchMethodException: perfIOPrefetchStart [int, class java.lang.String]
D/AppTracker(13525): App Event: start
I/chromium(13525): [INFO:CONSOLE(0)] "The SSL certificate used to load resources from https://sandbox-webkit.lemonway.fr will be distrusted in the future. Once distrusted, users will be prevented from loading these resources. See https://g.co/chrome/symantecpkicerts for more information.", source:  (0)
I/chromium(13525): [INFO:CONSOLE(0)] "The SSL certificate used to load resources from https://sandbox-webkit.lemonway.fr will be distrusted in the future. Once distrusted, users will be prevented from loading these resources. See https://g.co/chrome/symantecpkicerts for more information.", source: https://sandbox-webkit.lemonway.fr/myapp/dev/?moneyInToken=123456789101112131415&lang=fr (0)

Do you have any ideas please ?

ActivityNotFoundException

I am having problem with starting web_view in android. I used flutter_facebook_connect which opens webview for facebook authentication. It works on iOS, however Android build seems to have problem. here is the build log.

Launching lib/main.dart on c5674b2c in debug mode...
Initializing gradle...
Resolving dependencies...
Running 'gradlew assembleDebug'...
Built build/app/outputs/apk/app-debug.apk (27.2MB).
Installing build/app/outputs/apk/app.apk...
I/FlutterActivityDelegate(13525): onResume setting current activity to this
Syncing files to device c5674b2c...
D/skia (13525): [SkFontMgr Android Parser] '/system/etc/fonts.xml' could not be opened
D/skia (13525): [SkFontMgr Android Parser] '/vendor/etc/fallback_fonts.xml' could not be opened
E/MethodChannel#flutter_webview_plugin(13525): Failed to handle method call
E/MethodChannel#flutter_webview_plugin(13525): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.veda.roomFinder/com.flutter_webview_plugin.WebviewActivity}; have you declared this activity in your AndroidManifest.xml?
E/MethodChannel#flutter_webview_plugin(13525): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1556)
E/MethodChannel#flutter_webview_plugin(13525): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1431)
E/MethodChannel#flutter_webview_plugin(13525): at android.app.Activity.startActivityForResult(Activity.java:3429)
E/MethodChannel#flutter_webview_plugin(13525): at android.app.Activity.startActivityForResult(Activity.java:3390)
E/MethodChannel#flutter_webview_plugin(13525): at com.flutter_webview_plugin.FlutterWebviewPlugin.openUrl(FlutterWebviewPlugin.java:55)
E/MethodChannel#flutter_webview_plugin(13525): at com.flutter_webview_plugin.FlutterWebviewPlugin.onMethodCall(FlutterWebviewPlugin.java:36)
E/MethodChannel#flutter_webview_plugin(13525): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:191)
E/MethodChannel#flutter_webview_plugin(13525): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:128)
E/MethodChannel#flutter_webview_plugin(13525): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#flutter_webview_plugin(13525): at android.os.MessageQueue.next(MessageQueue.java:125)
E/MethodChannel#flutter_webview_plugin(13525): at android.os.Looper.loop(Looper.java:124)
E/MethodChannel#flutter_webview_plugin(13525): at android.app.ActivityThread.main(ActivityThread.java:4960)
E/MethodChannel#flutter_webview_plugin(13525): at java.lang.reflect.Method.invokeNative(Native Method)
E/MethodChannel#flutter_webview_plugin(13525): at java.lang.reflect.Method.invoke(Method.java:511)
E/MethodChannel#flutter_webview_plugin(13525): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
E/MethodChannel#flutter_webview_plugin(13525): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
E/MethodChannel#flutter_webview_plugin(13525): at dalvik.system.NativeStart.main(Native Method)
I/FlutterActivityDelegate(13525): onResume setting current activity to this
W/DynamiteModule(13525): Local module descriptor class for com.google.firebase.auth not found.
W/IInputConnectionWrapper(13525): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper(13525): setComposingText on inactive InputConnection

Warning on android: 'overrides a deprecated API'

Note: C:\Users\seragud\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\flutter_webview_plugin-0.0.9+1\android\src\main\java\com\flutter_webview_plugin\WebviewActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

Error starting on ios

I tried to start the example on iOS. Following Error:

flutter_app_test/ios/Runner/GeneratedPluginRegistrant.m:6:9: fatal error: 'flutter_webview_plugin/FlutterWebviewPlugin.h' file not found #import <flutter_webview_plugin/FlutterWebviewPlugin.h> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. Could not build the application for the simulator. Error launching application on iPhone X.

On Android it works fine.

Link handling

Implementing the plugin as shown:

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      routes: {
        "/": (_) => new WebviewScaffold(
          url: "http://wckethman.com/htree/my-app/www/index.html",
          withJavascript: true,
        )
      },
    );
  }
}
This works fine but when clicking on tel: links "net::ERR_UNKNOWN_URL_SCHEME" thrown

Any suggestions?

IOS - Fullscreen params should hide topBar

On IOS the fullscreen param should hide the topBar with the "Done" button, currently it seems to hide the statusBar instead.

Maybe we can have 2 differents params to handle both cases.

Zoom support

I want zoom content in webview with gestures. Is it possible?

Get the source

I want to print the HTML as a PDF.
I am using the HTML print plugin for flutter.

There is no method to ask for the HTML from the webview it seems ?

Shut down of the webview screen

When I try to connect to any webpage, it works a few seconds and then it shuts down the webview screen.

This is log of the Flutter app:

I/cr_Ime  ( 4929): ImeThread is enabled.
E/chromium( 4929): [ERROR:interface_registry.cc(104)] Failed to locate a binder for interface: autofill::mojom::PasswordManagerDriver
W/art     ( 4929): Attempt to remove non-JNI local reference, dumping thread
D/EGL_emulation( 4929): eglMakeCurrent: 0xb4e054e0: ver 2 0 (tinfo 0xa9b26410)
W/art     ( 4929): Attempt to remove non-JNI local reference, dumping thread
W/cr_BindingManager( 4929): Cannot call determinedVisibility() - never saw a connection for the pid: 4929
W/IInputConnectionWrapper( 4929): finishComposingText on inactive InputConnection
W/art     ( 4929): Attempt to remove non-JNI local reference, dumping thread
W/art     ( 4929): Attempt to remove non-JNI local reference, dumping thread
W/art     ( 4929): Attempt to remove non-JNI local reference, dumping thread
W/art     ( 4929): Attempt to remove non-JNI local reference, dumping thread
W/art     ( 4929): Attempt to remove non-JNI local reference, dumping thread
W/art     ( 4929): Attempt to remove non-JNI local reference, dumping thread
W/art     ( 4929): Attempt to remove non-JNI local reference, dumping thread
W/art     ( 4929): Attempt to remove non-JNI local reference, dumping thread
W/art     ( 4929): Attempt to remove non-JNI local reference, dumping thread
W/art     ( 4929): Attempt to remove non-JNI local reference, dumping thread
W/art     ( 4929): Attempt to remove non-JNI local reference, dumping thread
I/art     ( 4929): Background partial concurrent mark sweep GC freed 12(352B) AllocSpace objects, 2(23MB) LOS objects, 11% free, 30MB/34MB, paused 13.058ms total 37.816ms
W/art     ( 4929): Attempt to remove non-JNI local reference, dumping thread
W/art     ( 4929): Attempt to remove non-JNI local reference, dumping thread
W/art     ( 4929): Attempt to remove non-JNI local reference, dumping thread
W/art     ( 4929): Attempt to remove non-JNI local reference, dumping thread
D/EGL_emulation( 4929): eglCreateContext: 0x84a16f20: maj 2 min 0 rcv 2
D/EGL_emulation( 4929): eglMakeCurrent: 0x84a16f20: ver 2 0 (tinfo 0xa6fda500)
D/EGL_emulation( 4929): eglMakeCurrent: 0x84a16f20: ver 2 0 (tinfo 0xa6fda530)
D/EGL_emulation( 4929): eglMakeCurrent: 0xb4e054e0: ver 2 0 (tinfo 0xa9b26410)
D/EGL_emulation( 4929): eglMakeCurrent: 0xb4e054e0: ver 2 0 (tinfo 0xa9b26410)
D/EGL_emulation( 4929): eglMakeCurrent: 0xb4e054e0: ver 2 0 (tinfo 0xa9b26410)
D/EGL_emulation( 4929): eglMakeCurrent: 0xb4e078e0: ver 2 0 (tinfo 0x92d39e60)

Is this only some Android emulator-related stuff, or it doesn't works at all? The code of my app is the same as the code in example/lib/main.dart folder of this project.

The same issue is on my phone, where it's also prints "Webview Destroyed".

Emulator: Pixel XL API 25 on Windows 10
My phone: Honor Holly, Android v4.4.2

WebViewScaffold should extend Scaffold, else snackbars, alertdialogs etc cannot be used.

While using Widget Webview, it is not possible to show AlertDialogs or SnackBars or ModalBottomSheets.

For instance, to show a snackbar, we'd either use Scaffold.of(context).showSnackBar(new SnackBar(...)...); or the method below:

              return new WebviewScaffold(
                key: _webViewScaffoldKey,
                userAgent: userAgentString,
                url: _getSubjectUrl(value),
                appBar: new StudentoAppBar(actions: <Widget>[
                  new IconButton(
                    icon: new Icon(Icons.file_download),
                    color: Colors.white,
                    onPressed: () {
                      _webViewScaffoldKey.currentState.showSnackBar(new SnackBar(
                        content: new Text("Sample text!"),
                        duration: new Duration(seconds: 5),
                        action: new SnackBarAction(
                          label: "CLICK ME",
                          onPressed: _clickedMe,
                        ),
                      ),);},
                  ),
                ],),
                withLocalStorage: true,
              );

These give errors:
1)

I/flutter ( 4430): ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
I/flutter ( 4430): The following NoSuchMethodError was thrown while handling a gesture:
I/flutter ( 4430): The method 'showSnackBar' was called on null.
I/flutter ( 4430): Receiver: null
I/flutter ( 4430): Tried calling: showSnackBar(Instance of 'SnackBar')
I/flutter ( 4430):

and 2)

I/flutter ( 4430): ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
I/flutter ( 4430): The following assertion was thrown while handling a gesture:
I/flutter ( 4430): Scaffold.of() called with a context that does not contain a Scaffold.
I/flutter ( 4430): No Scaffold ancestor could be found starting from the context that was passed to Scaffold.of(). This
I/flutter ( 4430): usually happens when the context provided is from the same StatefulWidget as that whose build
I/flutter ( 4430): function actually creates the Scaffold widget being sought.
I/flutter ( 4430): There are several ways to avoid this problem. The simplest is to use a Builder to get a context that
I/flutter ( 4430): is "under" the Scaffold. For an example of this, please see the documentation for Scaffold.of():
I/flutter ( 4430):   https://docs.flutter.io/flutter/material/Scaffold/of.html
I/flutter ( 4430): A more efficient solution is to split your build function into several widgets. This introduces a
I/flutter ( 4430): new context from which you can obtain the Scaffold. In this solution, you would have an outer widget
I/flutter ( 4430): that creates the Scaffold populated by instances of your new inner widgets, and then in these inner
I/flutter ( 4430): widgets you would use Scaffold.of().
I/flutter ( 4430): A less elegant but more expedient solution is assign a GlobalKey to the Scaffold, then use the
I/flutter ( 4430): key.currentState property to obtain the ScaffoldState rather than using the Scaffold.of() function.
I/flutter ( 4430): The context used was:
I/flutter ( 4430):   Builder
I/flutter ( 4430):
I/flutter ( 4430): When the exception was thrown, this was the stack:
I/flutter ( 4430): #0      Scaffold.of (package:flutter/src/material/scaffold.dart:944:5)

But both do not work. As for AlertDialog it is displayed behind this scaffold. I think that this is because WebviewScaffold extends StatefulWidget instead of Scaffold. Please fix.

fail on dart v2

flutter upgrade
flutter run --preview-dart-2

in the console you will see if complaining about hit test. did not look into it but just wanted to flag it here while i was working on this

Custom auth

Is it possible to create an Auth0 wrapper with this plugin?

Missing a way to change the dimension of rect

If I lunch the webview in a rect in non fullscreen mode, how do I change the rect dimension without reload the page in webview? I want to do this when the user rotate the screen.

Receiving Cookies in WebView

I was wondering, if it is possible to get data from cookies, set in the web view, to the flutter application. My use case is a custom auth mechanism which works by authentication with google on server side and sending a cookie with the client credentials in a cookie to the frontend (in this case my flutter app). Is this possible with this plugin?

I saw both #7 and #8 and am not sure about this approach because of the cookie instead of a redirect url and query parameters.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.