Reputation: 4277
I have enabled web support for my project, and after running flutter run -d chrome
I get the following error:
Launching lib/main.dart on Chrome in debug mode...
Syncing files to device Chrome...
Compiler message:
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapiauth2.dart:26:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
GoogleAuth.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapiauth2.dart:216:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
SigninOptionsBuilder.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapi.dart:351:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
HttpRequestPromise.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapi.dart:378:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
HttpRequest.fakeConstructor$() : super.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapi.dart:402:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
HttpBatch.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapi.dart:440:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
RpcRequest.fakeConstructor$();
^
Syncing files to device Chrome... 19,442ms (!)
Failed to compile application.
Tals-Macbook:matkonit talbarda$ flutter run -d chrome
Launching lib/main.dart on Chrome in debug mode...
Syncing files to device Chrome...
Compiler message:
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapiauth2.dart:26:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
GoogleAuth.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapiauth2.dart:216:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
SigninOptionsBuilder.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapi.dart:351:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
HttpRequestPromise.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapi.dart:378:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
HttpRequest.fakeConstructor$() : super.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapi.dart:402:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
HttpBatch.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapi.dart:440:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
RpcRequest.fakeConstructor$();
^
Syncing files to device Chrome... 17,899ms (!)
Failed to compile application.
How can I fix this?
Upvotes: 8
Views: 14642
Reputation: 1420
Use dart pub outdated to identify out-of-date package dependencies and get advice on how to update them. Best practices for dependency management include using the most recent stable package versions, so you can get the latest bug fixes and improvements.
open terminal and path to your app folder
and run flutter pub outdated to list all the outdated packages.
cmd:flutter pub outdated
and upgrade all the outdated pacakges to latest or resolvable version. and run from terminal flutter pub upgrade. to update outdated packages to latest one. then run your app.
more info:https://dart.dev/tools/pub/cmd/pub-outdated
Upvotes: 2
Reputation: 613
For some reasons the newer version of flutter stopped supporting dependencies with this format:
folding_cell: "^0.1.2"
instead, check your pubspec.yaml and change any dependency with that format to this:
folding_cell: ^1.0.0
I have used folding_cell as an example.
This solved the problem for me, hope it helps someone.
Upvotes: 1
Reputation: 61
I've noticed this issue was fixed in google_sign_in_web 0.9.0. So change the version in your pubspec.yaml file.
google_sign_in_web: ^0.9.1
Update 20/04/2020: If you have a dependency with respect to google_sign_in, then change that version in your pubspec.yaml file.
google_sign_in: 4.4.3
Before: However, when you're like me and you have a dependency with respect to google_sign_in, then you have some more stuff to change... If you change the google_sign_in_web to be 0.9.0 and you change the version of google_sign_in to be 4.4.1, then retrieving the packages will fail:
Because ${your_project_name} depends on google_sign_in 4.4.1 which depends on google_sign_in_web ^0.8.2, google_sign_in_web ^0.8.2 is required.
So, because ${your_project_name} depends on google_sign_in_web ^0.9.0, version solving failed.
pub get failed (1; So, because ${your_project_name} depends on google_sign_in_web ^0.9.0, version solving failed.)
In this case, you'll have to wait for google_sign_in to upgrade (I created pull request https://github.com/flutter/plugins/pull/2647), or temporarily do like me and:
1) Clone flutter plugins from https://github.com/flutter/plugins
mkdir /src
cd /src
git clone https://github.com/flutter/plugins.git
2) Change the file pubspec.yaml in /src/plugins/plugins/packages/google_sign_in/google_sign_in/pubspec.yaml
google_sign_in_web: ^0.9.0
3) Change your dependency in your project to point to the changed version of google_sign_in, i.e.
google_sign_in:
path: ../../flutter/plugins/packages/google_sign_in/google_sign_in
google_sign_in_web: ^0.9.0
Upvotes: 3