Want to download/create pdf through webview in flutter If you are the owner of html page, you can check workaround that works for me. In source of your html page add onclick function for specific resource links:
1 2 3 4 5 | function downloadpdf() { var currentHref = window.location.href; window.history.pushState(null, null, '/app/somepdf.pdf'); setTimeout(() => window.location.replace(currentHref), 1000); } |
In Flutter code add listener:
1 2 3 4 5 6 7 | StreamSubscription<String> _onWebViewUrlChanged; _onWebViewUrlChanged = FlutterWebviewPlugin().onUrlChanged.listen((String url) { if (url.contains('.pdf')) { launchURL(url); } }); |
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.