Skip to content

Commit

Permalink
Fixed js execution problems in new webview impl
Browse files Browse the repository at this point in the history
  • Loading branch information
CircuitCoder committed Nov 11, 2022
1 parent ac066d7 commit 8b451fa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class _PlatformAdaptingHomePageState extends State<PlatformAdaptingHomePage> {
}

void _initSelf() async {
await webview.reload();
_webViewListener =
webview.stream(WebViewOwner.Main).listen(_onReceivedMessage);
topController = PageController(
Expand Down
6 changes: 2 additions & 4 deletions lib/utilities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,10 @@ class WebViewManager {
await cont.runJavascript(await rootBundle.loadString('assets/codes.js'));
}

Future<String> run(String js) async {
Future<void> run(String js) async {
if (_cont == null) throw "Not initialized";
log("[Webview] Run script $js");
String result = await _cont!.runJavascriptReturningResult(js);
log("[Webview] Result: $result");
return result;
await _cont!.runJavascript(js);
}

Stream<WebViewEvent> stream(WebViewOwner owner) {
Expand Down

0 comments on commit 8b451fa

Please sign in to comment.