skip to Main Content

Getting Error: The type ‘JSObject’ can’t be used as supertype. error but I havent used dart.js anywhere in my code and unable to deploy my app to vercel.

enter image description here

below is my pubspec:

name: appname
description: "A new Flutter project."
publish_to: 'none'
version: 0.1.0

environment:
  sdk: '>=3.2.5 <4.0.0'

dependencies:
  flutter:
    sdk: flutter
  get: ^4.6.6
  font_awesome_flutter: ^10.6.0
  http: ^1.2.0
  flutter_dotenv: ^5.1.0
  

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: true

assets:
  - .env

2

Answers


  1. The update 0.4.0 of web has already addressed the issues shown in the error. From the changelog:

    Remove implements JSObject from all types.

    For example, the class definition for ReadableStream in 0.3.0 was:

    class ReadableStream implements JSObject {
    

    It is now has changed to:

    class ReadableStream {
    

    The http package depends on the web package. In the version 1.2.0 of http, it depends on web with this version constraint:

    web: '>=0.3.0 <0.5.0'
    

    To fix the issue, simply depends the web package directly in your pubscpec. It is safe to use version 0.4.0 and above since it still meet the constraints shown above.

    In your pubspec file:

    dependencies:
      web: ^0.4.0
    

    Now another problem arises, the flutter_test package may not be compatible with these changes. If you’re not using flutter_test, you can simply remove it from the dev_dependencies. If you’re using it, you can try upgrading the Flutter SDK to the version that has flutter_test supports web ≥ 0.4.0.

    Login or Signup to reply.
  2. I was able to get pass this issue. Here’s my steps:

    Switch to beta channel

    flutter channel beta
    

    Upgrade SDK

    flutter upgrade
    

    Upgrade dependencies

    flutter pub upgrade
    

    Deploy to vercel and issue should go away

    Looking forward on web: ^0.4.2 support in #flutter stable channel

    Thanks @Dhafin Rayhan

    Hope it helps

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search