Im calling an html page in flutter using flutter_inappwebview package. Now i have create a function in javascript and i want to pass data in the function from flutter.I want solution that will work on every platform.
So i have done it like :
await webViewController?.evaluateJavascript(source: """ (function() {
if (window.receivecmpdata) {
window.receivecmpdata('$data');
console.log('Sent to JavaScript: $data');
} else {
console.log('receivecmpdata function is not defined');
}
})();
""");
It is working on windows but in web its not working.
SO i have treied passing the data in the cookies : await cookieManager.setCookie( url: WebUri("http://192.168.29.120"), // Use your domain here name: "billdata", value: "your_value_here", expiresDate: DateTime.now().add(Duration(days: 30)).millisecondsSinceEpoch, isHttpOnly: false, isSecure: false, // Set true for HTTPS only );
But this give error like
- SecurityError: Failed to read a named property 'console' from 'Window': Blocked a frame with origin "http://localhost:63961" from accessing a cross-origin frame.
2)SecurityError: Failed to read a named property 'history' from 'Window': Blocked a frame with origin "http://localhost:63961" from accessing a cross-origin frame.
3)Access to XMLHttpRequest at 'http://gc.kis.v2.scr.kaspersky-labs.com/7D8B79A2-8974-4D7B-A76A-F4F29624C06BSRPpuIkUKS8xuha8q3mQnZS5cgyjZ2cMLdA80akhF7KaSUR6T1U2ki3C93iAgkl_y_K6-wIjBC_fmRK3zpdvmQ/init?data=eyJ1cmwiOiJodHRwOi8vMTkyLjE2OC4yOS4xMjAvcnB0Q2hhbGxhblByaW50L3JwdENoYWxsYW5QcmludC5odG1sIiwicGx1Z2lucyI6IndzbSZ2cyZ3bnQmdWEmY2EmY2ImeGhyX2NvbnRlbnQiLCJkYXRhIjp7ImRhdGEiOlt7InBsdWdpbiI6IndzbSIsInBhcmFtZXRlcnMiOiJ7XCJyZWZlcnJlclwiOlwiaHR0cDovL2xvY2FsaG9zdDo2Mzk2MS9cIixcInN0dWJJZFwiOlwiXCJ9In0seyJwbHVnaW4iOiJ3bnQiLCJwYXJhbWV0ZXJzIjoie1wicmVmZXJyZXJcIjpcImh0dHA6Ly9sb2NhbGhvc3Q6NjM5NjEvXCJ9In0seyJwbHVnaW4iOiJ4aHJfY29udGVudCIsInBhcmFtZXRlcnMiOiJ7XCJyZWZlcnJlclwiOlwiaHR0cDovL2xvY2FsaG9zdDo2Mzk2MS9cIn0ifV19LCJpc1RvcExldmVsIjpmYWxzZSwicGFnZVN0YXJ0VGltZSI6MCwibmF2aWdhdGlvblN0YXJ0VGltZSI6MTc0MDY1MjEwMDg5OX0%3D&nocache=10c00&tm=2025-02-27T10%3A28%3A22.707Z' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.