我已经为我的项目启用了Web支持,在运行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... 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.
我该怎么补救呢?
4条答案
按热度按时间4nkexdtk1#
我注意到这个问题在google_sign_in_web 0.9.0中得到了修复,所以请在pubspec.yaml文件中更改版本。
2020年4月20日更新:如果您对google_sign_in有依赖关系,那么请在pubspec.yaml文件中更改该版本。
之前:然而,当你像我一样,对google_sign_in有依赖关系时,你就有更多的东西需要更改...如果你将google_sign_in_web更改为0.9.0,并将google_sign_in的版本更改为4.4.1,那么检索软件包将失败:
在这种情况下,你必须等待google_sign_in升级(我创建了pull request https://github.com/flutter/plugins/pull/2647),或者暂时像我一样:
1)从https://github.com/flutter/plugins克隆flutter插件
2)更改/src/插件/插件/软件包/google_sign_in/pubspec.yaml中的文件pubspec.yaml
3)更改项目中的依赖项以指向更改后的google_sign_in版本,即
yduiuuwa2#
换到beta频道。
gstyhher3#
由于某些原因,新版本的flutter不再支持这种格式的依赖项:
folding_cell: "^0.1.2"
,而是检查pubspec.yaml,并将该格式任何依赖项更改为:我已经用folding_cell作为一个例子。这为我解决了这个问题,希望它能帮助到别人。ctehm74n4#
使用dart pub outdated来识别过时的包依赖项,并获取有关如何更新它们的建议。依赖项管理的最佳实践包括使用最新的稳定包版本,以便您可以获得最新的错误修复和改进。
打开终端和路径到你的应用程序文件夹和运行flutter发布过时列出所有过时的软件包.
cmd:flutter发布过期
并升级所有过时的packakges到最新或resolvable版本.并运行从终端flutter酒吧升级.更新过时的软件包到最新的一个.然后运行你的应用程序.
more info:https://dart.dev/tools/pub/cmd/pub-outdated