-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The web project did not receive the onLoadStop callback, as well as the addJavaScriptHandler and evaluateJavascript methods #2217
Comments
NOTE: This comment is auto-generated. Are you sure you have already searched for the same problem? Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem! If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue. In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding Following these steps can save you, me, and other people a lot of time, thanks! |
+1 I've checked below issues/PRs, but couldn't find solution.
CC: @pichillilorenzo |
You can try the combination of the following versions, which works fine with me. |
Is this encountered in a new project or after modifying the version number of an old project? |
@MichaelSSY The reason for the issue you encountered is that the Flutter version is too high and needs to be lowered. Have you also modified the Flutter version? |
It shouldn't be an issue with the Flutter version, as our Flutter version is already very low. Below is the version information:
|
@MichaelSSY Try creating a new project according to the version I provided? |
Solved @ #2058 |
May I ask what is your version of Flutter? I am currently using 3.10.6, but I cannot upgrade it now as it will affect other functions. Has version 3.10.6 been resolved? |
did you try to add this code in your <script type="application/javascript" src="assets/packages/flutter_inappwebview_web/assets/web/web_support.js" defer></script> |
I tried it on 3.22.2 & 3.19.6 |
@fawdlstty I have used exactly the same versions as you told me, below screenshots for reference. ![]() ![]() However, I am still getting below error though, upon calling |
@skalex4 @MichaelSSY @yashharkhani did any of you find a solution for Flutter web to receive a event or a message from JSlayer to Flutter Layer? if yes, can you please let me know how any of you did resolve this ? |
@sriramkondeti Can you confirm that this project was created in the current version of Flutter environment, and that you have added the following content under <script type="application/javascript" src="assets/packages/flutter_inappwebview_web/assets/web/web_support.js"
defer></script> |
If so, then you may need to show your code for calling |
Here you go @fawdlstty
|
Yes Sir, this is in place. ![]() |
To make things easier, I am just instantiating a Webview to load HTML Data, if token of that HTML data expires, I want to get a new token and refresh the Webview |
@sriramkondeti, please use below for web package. As well as match the domain of webview url and flutter app.
Note: It won't work on localhost while in debug mode, you'll have to deploy the app and check. more info Credit goes to @p-mazhnik for this. |
Absolutely will deploy and test this, Thanks a ton @skalex4, this resolved Last question, does ![]() |
Hello, I am using Flutter3.19.6 and still get the following error, which is very strange!!! @sriramkondeti @skalex4
![]() ![]() ![]() |
Hi @MichaelSSY, Could you please try 6.0.0 once and check once
|
When I run the web version using flutter-inappwebview: ^ 6.0.0 or flutter-inappwebview: 6.0.0-rc.3, the JS event will report an error: |
Hi @MichaelSSY @sriramkondeti, I've create custom class to handle the events from webview using js_interops /// This code is used to handle events triggered by JavaScript and communicate with the Flutter app package.
import 'dart:convert';
import 'dart:js_interop';
import 'dart:js_interop_unsafe';
import 'package:flutter/material.dart';
@JS('callDartFunction')
external void executeDartHandler();
class DartEventHandler {
DartEventHandler() {
globalContext['executeDartHandler'] = handleEvent.toJS;
}
void handleEvent(String eventType, String payload) {
try {
// Event payload will be stringified from JS and then transmitted to dart.
Map<String, dynamic> eventData = {};
if (payload.isNotEmpty) {
eventData = json.decode(payload);
}
switch (eventType) {
case 'printMessage':
printMessage(payload);
break;
//....add custom events handlers here
default:
break;
}
} catch (e, st) { }
}
void printMessage(String message) {
debugPrint('Message from Webview: $message');
}
}
Invoke this class from main.dart void main() {
DartEventHandler(); // JS communication handler
runApp(...);
} Trigger from JS: window.parent.executeDartHandler(
eventType,
JSON.stringify(payload)
); Hope this helps!! CC: @pichillilorenzo |
Hello, I'm looking for |
The web project did not receive the onLoadStop callback, as well as the addJavaScriptHandler and evaluateJavascript methods
The text was updated successfully, but these errors were encountered: