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

evaluateJavascript() throwing exception in iOS #37

Open
taw1313 opened this issue Jan 4, 2021 · 2 comments
Open

evaluateJavascript() throwing exception in iOS #37

taw1313 opened this issue Jan 4, 2021 · 2 comments

Comments

@taw1313
Copy link

taw1313 commented Jan 4, 2021

I am getting the following exception being thrown using your example code while attempting to run it on iOS ( Android is working as expected )

PlatformException (PlatformException(evaluateJavaScript_failed, Failed evaluating JavaScript, JavaScript string was: '$(".note-placeholder").html("Your text here...");'
Error Domain=WKErrorDomain Code=5 "JavaScript execution returned a result of an unsupported type" UserInfo={NSLocalizedDescription=JavaScript execution returned a result of an unsupported type}, null))

---- following is my flutter doctor data --------------
[✓] Flutter (Channel dev, 1.25.0-4.0.pre, on macOS 11.1 20C69 darwin-x64, locale en-US)
• Flutter version 1.25.0-4.0.pre at /Users/tawilson/development/flutter
• Framework revision a7f5fd5360 (5 weeks ago), 2020-11-30 13:14:13 +0100
• Engine revision 20caf54969
• Dart version 2.12.0 (build 2.12.0-76.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/tawilson/Library/Android/sdk
• Platform android-30, build-tools 29.0.2
• ANDROID_HOME = /Users/tawilson/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.3, Build version 12C33
• CocoaPods version 1.9.3

[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.52.1)
• VS Code at /Users/tawilson/Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.18.0

[✓] Connected device (3 available)
• SM S367VL (mobile) • 520087f159ef55db • android-arm • Android 8.0.0 (API 26) (emulator)
• QuadT (mobile) • 5ae46cb82de36b7e4b9dc40c0aca59b428ac066e • ios • iOS 13.7
• iPhone 11 (mobile) • BE5167DD-635B-4DB1-A533-DD91397A6E26 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-5 (simulator)

• No issues found!

@taw1313
Copy link
Author

taw1313 commented Jan 4, 2021

I have a work around for now...
in your html_editor.dart a modified setHint() to use document.getElementsByClassName.

setHint(String text) { String hint = "document.getElementsByClassName('note-placeholder')[0].innerHTML = '" + text + "';"; _controller.evaluateJavascript(hint); }

which works in iOS and Android but seems odd that I had to do that to get it to work in iOS...
(feels like I have a build environment issue but I do not see anything wrong )

above work around only works for iOS < 14.
same type of error occurs using above work around or original solution with iOS 14.3

@tneotia
Copy link

tneotia commented Feb 20, 2021

I forked this library and have made some pretty massive changes to it, you can find it here. I've fixed this issue (and many others) in that library.

I would have preferred to create PRs but it seems this library is lacking maintenance so I took it upon myself.

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

2 participants