9个月前我做了一个Flutter Web应用程序,今天当我再次打开代码来修复一个问题时,我无法在Web上运行它。
我已经更新了Flutter/Dart版本和所有的包依赖项。
当我尝试在Web上运行它时,我得到了与'allowInterop'方法相关的错误:
../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart:73:23: Error: The method 'allowInterop' isn't defined for the class 'Firestore'.
- 'Firestore' is from 'package:cloud_firestore_web/src/interop/firestore.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
var nextWrapper = allowInterop((Object? noValue) {
^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart:100:30: Error: The method 'allowInterop' isn't defined for the class 'Firestore'.
- 'Firestore' is from 'package:cloud_firestore_web/src/interop/firestore.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
var updateFunctionWrap = allowInterop((transaction) =>
^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart:178:11: Error: The method 'allowInterop' isn't defined for the class 'LoadBundleTask'.
- 'LoadBundleTask' is from 'package:cloud_firestore_web/src/interop/firestore.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
allowInterop((firestore_interop.LoadBundleTaskProgressJsImpl data) {
^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart:188:21: Error: The method 'allowInterop' isn't defined for the class 'LoadBundleTask'.
- 'LoadBundleTask' is from 'package:cloud_firestore_web/src/interop/firestore.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
jsObject.then(allowInterop((value) {
^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart:190:11: Error: The method 'allowInterop' isn't defined for the class 'LoadBundleTask'.
- 'LoadBundleTask' is from 'package:cloud_firestore_web/src/interop/firestore.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
}), allowInterop((error) {
^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart:331:9: Error: The method 'allowInterop' isn't defined for the class 'DocumentReference'.
- 'DocumentReference' is from 'package:cloud_firestore_web/src/interop/firestore.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
allowInterop((firestore_interop.DocumentSnapshotJsImpl snapshot) {
^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart:335:26: Error: The method 'allowInterop' isn't defined for the class 'DocumentReference'.
- 'DocumentReference' is from 'package:cloud_firestore_web/src/interop/firestore.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final errorWrapper = allowInterop((e) => controller.addError(e));
^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart:420:9: Error: The method 'allowInterop' isn't defined for the class 'Query<T>'.
- 'Query' is from 'package:cloud_firestore_web/src/interop/firestore.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
allowInterop((firestore_interop.QuerySnapshotJsImpl snapshot) {
^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart:423:26: Error: The method 'allowInterop' isn't defined for the class 'Query<T>'.
- 'Query' is from 'package:cloud_firestore_web/src/interop/firestore.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final errorWrapper = allowInterop((e) => controller.addError(e));
^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart:626:9: Error: The method 'allowInterop' isn't defined for the class 'QuerySnapshot'.
- 'QuerySnapshot' is from 'package:cloud_firestore_web/src/interop/firestore.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/firestore.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
allowInterop((s) => callback(DocumentSnapshot.getInstance(s)));
^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-5.1.3/lib/src/interop/auth.dart:378:27: Error: The method 'allowInterop' isn't defined for the class 'Auth'.
- 'Auth' is from 'package:firebase_auth_web/src/interop/auth.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-5.1.3/lib/src/interop/auth.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final nextWrapper = allowInterop((auth_interop.UserJsImpl? user) {
^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-5.1.3/lib/src/interop/auth.dart:382:28: Error: The method 'allowInterop' isn't defined for the class 'Auth'.
- 'Auth' is from 'package:firebase_auth_web/src/interop/auth.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-5.1.3/lib/src/interop/auth.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final errorWrapper = allowInterop((e) => _changeController!.addError(e));
^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-5.1.3/lib/src/interop/auth.dart:417:27: Error: The method 'allowInterop' isn't defined for the class 'Auth'.
- 'Auth' is from 'package:firebase_auth_web/src/interop/auth.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-5.1.3/lib/src/interop/auth.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final nextWrapper = allowInterop((auth_interop.UserJsImpl? user) {
^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-5.1.3/lib/src/interop/auth.dart:422:11: Error: The method 'allowInterop' isn't defined for the class 'Auth'.
- 'Auth' is from 'package:firebase_auth_web/src/interop/auth.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-5.1.3/lib/src/interop/auth.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
allowInterop((e) => _idTokenChangedController!.addError(e));
^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging_web-3.2.8/lib/src/interop/messaging.dart:64:27: Error: The method 'allowInterop' isn't defined for the class 'Messaging'.
- 'Messaging' is from 'package:firebase_messaging_web/src/interop/messaging.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging_web-3.2.8/lib/src/interop/messaging.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final nextWrapper = allowInterop((payload) {
^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging_web-3.2.8/lib/src/interop/messaging.dart:67:28: Error: The method 'allowInterop' isn't defined for the class 'Messaging'.
- 'Messaging' is from 'package:firebase_messaging_web/src/interop/messaging.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging_web-3.2.8/lib/src/interop/messaging.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final errorWrapper = allowInterop((e) {
^^^^^^^^^^^^
../../flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:48:14: Error: Method not found: 'allowInterop'.
getPath: allowInterop(strategy.getPath),
^^^^^^^^^^^^
../../flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:49:15: Error: Method not found: 'allowInterop'.
getState: allowInterop(strategy.getState),
^^^^^^^^^^^^
../../flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:50:26: Error: Method not found: 'allowInterop'.
addPopStateListener: allowInterop(strategy.addPopStateListener),
^^^^^^^^^^^^
../../flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:51:25: Error: Method not found: 'allowInterop'.
prepareExternalUrl: allowInterop(strategy.prepareExternalUrl),
^^^^^^^^^^^^
../../flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:52:16: Error: Method not found: 'allowInterop'.
pushState: allowInterop(strategy.pushState),
^^^^^^^^^^^^
../../flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:53:19: Error: Method not found: 'allowInterop'.
replaceState: allowInterop(strategy.replaceState),
^^^^^^^^^^^^
../../flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:54:9: Error: Method not found: 'allowInterop'.
go: allowInterop(strategy.go),
^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_web-2.0.1/lib/src/interop/utils/utils.dart:89:12: Error: Method not found: 'allowInterop'.
return allowInterop(dartObject);
^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_web-2.0.1/lib/src/interop/utils/utils.dart:124:27: Error: Method not found: 'allowInterop'.
return PromiseJsImpl<S>(allowInterop((
^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-3.1.0/lib/src/interop/utils/utils.dart:69:14: Error: Method not found: 'allowInterop'.
return allowInterop(object);
^^^^^^^^^^^^
Failed to compile application.
我的“Flutter doctor -v”:
[✓] Flutter (Channel stable, 3.3.9, on macOS 12.6 21G115 darwin-x64, locale en-PT)
• Flutter version 3.3.9 on channel stable at /Users/tiago/Code/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision b8f7f1f986 (13 days ago), 2022-11-23 06:43:51 +0900
• Engine revision 8f2221fbef
• Dart version 2.18.5
• DevTools version 2.15.0
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/tiago/Library/Android/sdk
• Platform android-33, build-tools 30.0.3
• ANDROID_HOME = /Users/tiago/Android/Sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14A400
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.3)
• 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 11.0.13+0-b1751.21-8125866)
[✓] VS Code (version 1.72.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 12.6 21G115 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 107.0.5304.121
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
对此有什么建议吗?
1条答案
按热度按时间0yycz8jy1#
check class were duplicate the packages import'package:firebase/firestore. dart';将其替换为import'package:cloud_firestore/cloud_firestore. dart';