Я получил код html с одного сайта и попытался использовать его в моем веб-просмотре flutter, но ничего не вышло. Когда я обычно открываю файл из chrome, все выглядит хорошо. Это мой код html:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script src="https://export.otpusk.com/api/session?access_token=***"></script>
<script src="https://export.otpusk.com/js/onsite/"></script>
<script src="https://export.otpusk.com/js/order"></script>
</body>
</html>
И как я его использую:
String filePath = "assets/index.html";
WebViewController webViewController;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("App bar"),),
body: WebView(
initialUrl: 'about:blank',
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webview){
webViewController = webview;
_loadHtmlFromAssets();
},
),
);
}
_loadHtmlFromAssets() async{
String fileHtmlContents = await rootBundle.loadString(filePath);
webViewController.loadUrl(Uri.dataFromString(fileHtmlContents,mimeType: 'text/html',encoding: Encoding.getByName('utf-8')).toString());
}
В консоли я получаю что-то вроде этого:
I/chromium(13344): [INFO:CONSOLE(1)] "A parser-blocking, cross site (i.e. different eTLD+1) script, https://export.otpusk.com/jsapi/onsite.min.js?_time=20200525, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message. See https://www.chromestatus.com/feature/5718547946799104 for more details.", source: https://export.otpusk.com/js/onsite/ (1)
I/chromium(13344): [INFO:CONSOLE(1)] "A parser-blocking, cross site (i.e. different eTLD+1) script, https://export.otpusk.com/jsapi/onsite.min.js?_time=20200525, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message. See https://www.chromestatus.com/feature/5718547946799104 for more details.", source: https://export.otpusk.com/js/onsite/ (1)
I/chromium(13344): [INFO:CONSOLE(24)] "Uncaught SecurityError: Failed to read the 'cookie' property from 'Document': Cookies are disabled inside 'data:' URLs.", source: https://export.otpusk.com/jsapi/onsite.min.js?_time=20200525 (24)
Пожалуйста помогите мне, как я могу это исправить или как я могу загрузить только часть сайта, а не весь?