WebView in ListView without assigning its dimensions. I wrapped WebView into a SizedBox and assigned it’s height like this:
1 2 3 4 5 6 7 8 | _webViewController .evaluateJavascript("document.body.clientHeight") .then((height) { print("Height of Page is: $height}"); setState(() { sizedBoxHeight = double.parse(height); }); }); |
For a more advanced solution we can use JavascriptChannels like this:
1 2 3 4 5 6 7 8 9 | javascriptChannels: Set.from([ JavascriptChannel( name: 'RenderedWebViewHeight', onMessageReceived: (JavascriptMessage message) { setState(() { sizedBoxHeight = double.parse(message.message); }); ]), |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.