Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
877 views
in Technique[技术] by (71.8m points)

flutter - InAppWebView - inject text in the html

I am using flutter_inappwebview. I need to insert text into the content of the page loaded with the initialUrl. I don't want to use loadData because I need to load from an url.

The text is the content of the file that the user opens via a button widget.

How can I do this?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I ended up using loadData with a baseUrl. That way I still load the url with the custom data that I need.

Besides, one can also insert values using evaluateJavascript:

onChanged: (String value) async {
             await webView.evaluateJavascript(
                 source: "document.getElementById('element-id').value = '$value'; ");
          },

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...