Skip to content
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

[BUG][iOS] Calling replaceText() on iOS throws Invalid argument(s): Result of JavaScript execution returned a null value. Use runJavascript when expecting a null return value. #216

Open
Kuroketsu opened this issue Dec 17, 2024 · 1 comment

Comments

@Kuroketsu
Copy link

Kuroketsu commented Dec 17, 2024

Describe the bug
Calling replaceText() on iOS throws Unhandled Exception: Invalid argument(s): Result of JavaScript execution returned a null value. Use runJavascript when expecting a null return value.

To Reproduce
Steps to reproduce the behavior:

  1. Copy code from demo sample app
  2. run on iOS
  3. See error
Unhandled Exception: Invalid argument(s): Result of JavaScript execution returned a `null` value. Use `runJavascript` when expecting a null return value.
#0      WebKitWebViewController.runJavaScriptReturningResult (package:webview_flutter_wkwebview/src/webkit_webview_controller.dart:481:7)
<asynchronous suspension>
#1      WebViewXController.callJsMethod (package:quill_html_editor/src/widgets/webviewx/src/controller/impl/mobile.dart:124:20)
<asynchronous suspension>
#2      QuillHtmlEditorState._replaceText (package:quill_html_editor/src/quill_editor_wrapper.dart:529:12)
<asynchronous suspension>
#3      QuillEditorController.replaceText (package:quill_html_editor/src/quill_editor_wrapper.dart:1416:12)
<asynchronous suspension>

Expected behavior
Should not throw an exception and replaceText() should work properly.

Smartphone (please complete the following information):

  • Device: iPhone 16 Plus
  • OS: iOS 18.0

Package version used:

  • quill_html_editor: ^2.2.8

Flutter Doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.3, on macOS 15.0.1 24A348 darwin-arm64 (Rosetta), locale en-PH)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] VS Code (version 1.80.1)
[✓] Connected device (5 available)
[✓] Network resources

Additional context
I think this issue is related to the callJsMethod of the webviewx_plus package as it uses runJavascriptReturningResult instead of the regular runJavaScript.
I found it on the stackoverflow:
https://stackoverflow.com/questions/76048861/flutter-runjavascriptreturningresult-returns

@Kuroketsu
Copy link
Author

Kuroketsu commented Dec 19, 2024

I resolved the issue on this pull request.
#218

I jast added an empty string return for the javascript method replaceSelection() so that it does not throw the exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant