How to read website content in Flutter webview? - flutter

I want to read the contents of a page opened with Flutter webview. Before the page opens, the user needs to manually enter the information on the previous page, and I have no chance to do this in the background with http. How can I get the data on the opened page with WebView (which can be webview_flutter or flutter_webview_plugin). Thanks in advance.

There is nothing out of the box exactly for that purpose, however, webview_flutter supports communicating with the page using JavascriptChannel. Using controller.evaluateJavascript, you can inject a script that sends the page content to the channel using postMessage. See the examples in the plugin repo.

Related

I'm using flutter_webview_plugin and there is a web page in which a button implemented with the window.print function, i need to make that functional

I'm using flutter_webview_plugin in my flutter application, where I've set some URL to display in the app. The website which I'm using has a button to print the current page. That button is wrapped with this javascript
function myPrint(){
window.print();
}
That function is properly working on the PC and Mobile browsers perfectly, but how could I make that work on the flutter app too?
use this plugin it's so good and has a lot of events, methods, and options
InAppWebView

TWA bases app sometime showing URL and sometime working, even Assetlink.json uploaded properly

I have website (https://www.kriscent.com/product/kart-supermarket/). I created PWA of that after that I uploaded it on Play store by using TWA(Trusted Web Activities), App URL is https://play.google.com/store/apps/details?id=in.kriscent.kartlite.
The URL of website always show in app, So I uploaded the assetlink.json (URL: https://www.kriscent.com/.well-known/assetlinks.json).
After uploading the assetlinks.json, When I run my app, the website URL disappeared but when I switched on other link in the app then the URL shows again.
I don,t know what is happening. Please help me if anybody has idea to resolve this issue.
enter image description here
enter image description here
The problem is that, when navigating to a product detail page, you are using a different origin than the one used to open the Trusted Web Activity and that doesn't have Digital Asset Links setup:
When the application is started, it opens https://www.kriscent.com/, which is correctly validated.
When clicking on a product, the user is take to https://kriscent.com/ (without www), which is a different origin, and is not validated in the Android app.
It is possible to get the Trusted Web Activity to work with multiple origins but, in this case, I'd recommend using a single origin for the initial URL and the navigations, as you will be able to take advantage of using the same service worker, browser storage, etc.

Precache html pages in flutter

I have a list of some HTML pages that i show in my web_view. The problem is that it will load slowly when network is slow or wont show at all if user is offline. So i want to pre-cache all the URLs before navigating to that page. After that I want to load from the cache and navigate through the URLs on swipe. (The Swipe part is done with URLs loading real-time). My question to you is how do I pre-cache every URLs and call it in my web_view later
If you are sure that those pages are static..I have a suggestion for you..
Like you said, you can pre-cache..
Initially, when internet is available you get the code of those URLs using
http package and store it in local storage, say some .txt file.
And then, when you want to show the page in your app, again..as it being static page, you can read the html code from local storage and show it in your app using html package.
Hope it answers your question.

Phone gap ios app - show pdf file with print/email options

I have a requirement to do the following task.
Inside a Phonegap iOS app, the user wants to view a pdf file after clicking a link which will load the pdf from the remote server.
And also user needs print, email functions with this document viewer.
So far I have tried following options.
Exit from the app when user click on the link and try to load the pdf throught the Safari. This is not working because user has to relogin for viewing the application.
Check with child-browser plugin. But it does not provide the options like print/email.
It'll be really great if some one can help on this who has similar experience.
Thanks

titanium webview - go to default browser when clicking links

in titanium, i'm using the webview to display a wordpress blog page, that is already formatted for mobile browser. instead of writing my own interface, this works as a good work around. the apps sole focus isn't the browser.
but my issue lies, when the user clicks a link outside of the initial displayed domain. i only want the main domain to be displayed in the apps browser. if any other link is clicked, that takes the user outside of that domain, i want to have it open in the phones default browser.
can anyone point me in a direction for this. i tried adding a listener to try and catch link clicks, however, i've been unsuccessful.
thanks
in this blog posting I show how to find links in a webpage and change the link behavior. Using the same method, you can intercept the links and redirect to opening the URL in the devices default browser
One solution would be to catch the onclick() Event by Javascript inside the WebView (your blog code) and handle this by a custom handler. Maybe you can inject the javascript event handler code into the running WebView through Titanium.
Another solution is to make your blogposts readable for app technology and create a new data interface. This is the way I would do. For that I would use some kind of JSON data format and a simple REST Interface to get the data.
I don't think bove solutions are that simple. If you want an app with "great feeling", you'll have to handle the events by your own. Maybe Phonegap would be a better solution four your problem. But there you will still need a kind of REST/JSON interface for your blog data. The idea behind an app is, that the main code is in your app and you get the content from a remote source. This way you'll get an advantage compared to a simple browser optimized site.