Shahxad-Akram / webview_flutter_plus

An extension of webview_flutter to load HTML,CSS and Javascript even from Assets or Strings.
https://pub.dev/packages/webview_flutter_plus
Other
57 stars 49 forks source link

Error when loading from dataFromString and not url #3

Open djock opened 4 years ago

djock commented 4 years ago

I have the following issue when using the plugin:

W/System (17063): A resource failed to call release. W/System (17063): A resource failed to call release. W/PlatformViewsController(17063): Creating a virtual display of size: [1080, 6675] may result in problems(https://github.com/flutter/flutter/issues/2897).It is larger than the device screen size: [1080, 1884]. E/InputMethodManager(17063): b/117267690: Failed to get fallback IMM with expected displayId=37 actual IMM#displayId=0 view=io.flutter.plugins.webviewflutter.InputAwareWebView{6511e40 VFEDHVC.. ........ 0,0-1080,6675} I/chromium(17063): [INFO:CONSOLE(123)] "Uncaught ReferenceError: jQuery is not defined", source: E/InputMethodManager(17063): b/117267690: Failed to get fallback IMM with expected displayId=37 actual IMM#displayId=0 view=io.flutter.plugins.webviewflutter.InputAwareWebView{6511e40 VFEDHVC.. ........ 0,0-1080,6675} E/chromium(17063): [ERROR:aw_browser_terminator.cc(125)] Renderer process (28337) crash detected (code -1).

And this is my implementation:

SizedBox(
          height: _containerHeight,
          child: WebViewPlus(
            onWebViewCreated: (controller) {
              controller = controller;
              controller.loadUrl(Uri.dataFromString(widget.articleModel.body,
                  mimeType: 'text/html',
                  encoding: Encoding.getByName('utf-8'))
                  .toString());
            },
            onPageFinished: (url) {
              controller.getHeight().then((double height) {
                print("Height:  " + height.toString());
                setState(() {
                  _containerHeight = height;
                });
              });
            },
            javascriptMode: JavascriptMode.unrestricted,
          ),
        );

The widget.articleModel.body does not contain any html or body tags, it's just paragraph tags

DFelten commented 4 years ago

I think the problem is not that you load data from a string, instead the problem is a WebView with a too large height. In Android it crashes when the height of the WebView is too high.

Currently I've got the same problem and searching for a solution. More information in this issue.