0

I am using webview_flutter to show a web page. I am using the below code to detect the platform, like is it android or ios. My below code is not working. Flutter webview - https://pub.dev/packages/webview_flutter I have added the below class in body.

class - view-withKeyboard


function applyAfterResize() {
            console.log(getMobileOperatingSystem());
            if (getMobileOperatingSystem() == 'ios') {
                if (originalPotion !== false) {
                    var wasWithKeyboard = $('body').hasClass('view-withKeyboard');
                    var nowWithKeyboard = false;
                        var diff = Math.abs(originalPotion - ($(window).width() + $(window).height()));
                        if (diff > 100) nowWithKeyboard = true;
                    $('body').toggleClass('view-withKeyboard', nowWithKeyboard);
                    if (wasWithKeyboard != nowWithKeyboard) {
                        //onKeyboardOnOff(nowWithKeyboard);
                    }
                }
            }
        }
        $(document).on('focus blur', '.white-div input[type=text]', function(e){
            //alert('here');
            if (getMobileOperatingSystem() == 'ios') {
              var $obj = $(this);
              var nowWithKeyboard = (e.type == 'focusin');
              $('body').toggleClass('view-withKeyboard', nowWithKeyboard);
              onKeyboardOnOff(nowWithKeyboard);
            }
        });
1
  • Can you show us the WebView widget on how you use it. Commented Dec 15, 2020 at 7:33

1 Answer 1

1

Enable JavascriptMOde first and use evaluateJavascript

WebView(
    javascriptMode: JavascriptMode.unrestricted,
    initialUrl: '',
    onWebViewCreated:
        (WebViewController webViewController) async {
      webViewController.evaluateJavascript(
          "javascript:(function() { " +
              "console.log('Test Test Test');" +
              "})()");
    },
  ),
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.