You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.
When passing to and returning from callJsMethod, the following inconsistency in behavior occurs:
On Android, when converting strings from JS to Dart, newlines, quotes and backslashes become escaped, and when doing the opposite the opposite happens (they become unescaped).
On iOS, JS to Dart strings are kept the same (as expected) but when converting from Dart to JS, instances of \n turn into actual newlines. Quotes remain the same.
On Web, strings are kept the same (as expected).
Steps to reproduce
Keep the following strings in mind:
String 1
the quick brown fox
"jumps over the\nlazy dog"
String 2
the quick brown fox "jumps over the\nlazy dog"
If on iOS, disable smart quotes or manually paste the strings.
Enter string 1 on the Dart text field
Click on "Dart to JS"
Click on "JS to Dart"
Enter string 1 on the HTML text field
Click on "JS to Dart"
Click on "Dart to JS"
Repeat the same steps for string 2 if needed
Android behavior
When string 1 is converted from Dart to JS:
Unsuccessful, prints the following:
I/chromium( 5718): [INFO:CONSOLE(1)] "Uncaught SyntaxError: Invalid or unexpected token"
When string 1 is converted from Dart to JS back to Dart:
N/A
When string 1 is converted from JS to Dart:
the quick brown fox\n\"jumps over the\\nlazy dog\"
(i.e. newlines, quotes and backslashes become escaped)
When string 1 is converted from JS to Dart back to JS:
the quick brown fox
"jumps over the\nlazy dog"
(i.e. newlines, quotes and backslashes become unescaped, and there is no net change)
When string 2 is converted from Dart to JS:
the quick brown fox "jumps over the
lazy dog"
When string 2 is converted from Dart to JS back to Dart:
the quick brown fox \"jumps over the\nlazy dog\"
iOS behavior
When string 1 is converted from Dart to JS:
Unsuccessful, PlatformException is thrown:
[VERBOSE-2:ui_dart_state.cc(198)] Unhandled Exception: PlatformException(evaluateJavaScript_failed, Failed evaluating JavaScript, JavaScript string was: 'load('the quick brown fox
"jumps over the\nlazy dog"')'
When string 1 is converted from Dart to JS back to Dart:
N/A
When string 1 is converted from JS to Dart:
the quick brown fox
"jumps over the\nlazy dog"
(as expected)
When string 1 is converted from JS to Dart back to JS.
(PlatformException is thrown)
When string 2 is converted from Dart to JS:
the quick brown fox "jumps over the
lazy dog"
When string 2 is converted from Dart to JS back to Dart:
the quick brown fox "jumps over the
lazy dog"
When string 2 is converted from JS to Dart:
the quick brown fox "jumps over the\nlazy dog"
(as expected)
When string 2 is converted from JS to Dart back to JS
the quick brown fox "jumps over the
lazy dog"
Web behavior
Everything works as expected
When string 1 is converted from Dart to JS:
the quick brown fox
"jumps over the\nlazy dog"
(as expected)
When string 1 is converted from Dart to JS back to Dart:
the quick brown fox
"jumps over the\nlazy dog"
(as expected)
When string 1 is converted from JS to Dart:
the quick brown fox
"jumps over the\nlazy dog"
(as expected)
When string 1 is converted from Dart to JS:
the quick brown fox
"jumps over the\nlazy dog"
(as expected)
Expected behavior
Strings are kept exactly the same when switching between programming languages, and do not mutate.
Background
I'm doing something similar but for JSON files. When passing information between languages, valid JSON files turn into invalid JSON files. I have to workaround this by doing the opposite with find and replace or something similar.
I was passing JSON in the first place, because maps didn't work as expected either.
The text was updated successfully, but these errors were encountered:
Sample code where bug is reproduced
This sample has a Dart text field on the top, and an HTML textarea on the bottom.
lib/main.dart
Summary
When passing to and returning from
callJsMethod
, the following inconsistency in behavior occurs:On Android, when converting strings from JS to Dart, newlines, quotes and backslashes become escaped, and when doing the opposite the opposite happens (they become unescaped).
On iOS, JS to Dart strings are kept the same (as expected) but when converting from Dart to JS, instances of
\n
turn into actual newlines. Quotes remain the same.On Web, strings are kept the same (as expected).
Steps to reproduce
Keep the following strings in mind:
String 1
String 2
If on iOS, disable smart quotes or manually paste the strings.
Android behavior
Unsuccessful, prints the following:
N/A
(i.e. newlines, quotes and backslashes become escaped)
(i.e. newlines, quotes and backslashes become unescaped, and there is no net change)
iOS behavior
Unsuccessful, PlatformException is thrown:
N/A
(as expected)
(PlatformException is thrown)
(as expected)
Web behavior
Everything works as expected
(as expected)
(as expected)
(as expected)
(as expected)
Expected behavior
Strings are kept exactly the same when switching between programming languages, and do not mutate.
Background
I'm doing something similar but for JSON files. When passing information between languages, valid JSON files turn into invalid JSON files. I have to workaround this by doing the opposite with find and replace or something similar.
I was passing JSON in the first place, because maps didn't work as expected either.
The text was updated successfully, but these errors were encountered: