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

Error: A value of type 'JSString' can't be assigned to a variable of type 'String' #1791

Open
1 of 5 tasks
ashitaprasad opened this issue Dec 14, 2024 · 1 comment
Open
1 of 5 tasks
Labels
bug Something isn't working needs triage

Comments

@ashitaprasad
Copy link

Describe the bug
Unable to build Flutter app for web

Launching lib/main.dart on Chrome in debug mode...
../../../.pub-cache/hosted/pub.dev/printing-5.13.4/lib/printing_web.dart:218:16: Error: 
A value of type 'JSString' can't be assigned to a variable of type 'String'.
              .toJS;
               ^
Failed to compile application.

Expected behavior
It should build for web

Flutter Doctor

[✓] Flutter (Channel stable, 3.24.3, on macOS 14.6.1 23G93 darwin-arm64, locale en-IN)
    • Flutter version 3.24.3 on channel stable at /Users/ap/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (3 months ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/ap/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.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 17.0.11+0-17.0.11b1207.24-11852314)

[✓] IntelliJ IDEA Community Edition (version 2023.1.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • 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

[✓] VS Code (version 1.95.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.102.0

[✓] Connected device (4 available)
    • Ashita’s iPhone (mobile)        • 00008030-000951A01A02402E • ios            • iOS 18.1 22B83
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.6.1 23G93
      darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.6.1 23G93
      darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome
      131.0.6778.140

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Desktop (please complete the following information):

  • iOS
  • Android
  • Browser
  • Windows
  • Linux
@ashitaprasad
Copy link
Author

ashitaprasad commented Dec 14, 2024

Upon further investigation I found the fix:

Changing

      script.innerHTML =
          '''function ${_frameId}_print(){var f=document.getElementById('$_frameId');f.focus();f.contentWindow.print();}'''
              .toJS;

to

      script.innerHTML =
          '''function ${_frameId}_print(){var f=document.getElementById('$_frameId');f.focus();f.contentWindow.print();}''';

JSString conversion using .toJS is no longer required.

There is already an open PR #1739 which fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

1 participant