I need to call a js function in a flutter app to load a payment dashboard page. So I use the WebViewPlus flutter package to do that. I write the HTML code inside the dart page and call with the help of WebViewPlus. it loads correctly. but when I call the js function in a button press it tries to load but gives an error. i.e "Uncaught (in promise) SecurityError: Failed to read the 'localStorage' property from 'Window': Storage is disabled inside 'data:' URLs.", How can I clear the storage issue in WebViewPlus package? my code is here
import 'package:flutter/material.dart';
import 'package:webview_flutter_plus/webview_flutter_plus.dart';
class WebViewStorage extends StatelessWidget {
const WebViewStorage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: WebViewPlus(
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (controller) {
controller.loadString('''<!DOCTYPE html>
<html>
<head>
<script src="https://elements.zwitch.io/zwitch.js"></script>
</head>
<body>
<div id="savingContainer"></div>
<script>
function myFunction() {
const credentials = {
token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
}
Zwitch.openSavingsAccount({
containerId: 'savingContainer',
credentials: credentials,
callbacks: {
onSuccess: (resp) => { console.log(resp); },
onError: (resp) => { console.log(resp); },
}
});
}
</script>
<h1>My First Heading</h1>
<button onclick="myFunction()">Submit</button>
</body>
</html>
''');
},
),
);
}
}