【问题标题】:Flutter "Error: Not found: 'dart:html' import 'dart:html';"颤振“错误:未找到:'dart:html'导入'dart:html';”
【发布时间】:2021-03-01 22:02:30
【问题描述】:

我正在尝试将 firebase 集成到我的颤振代码中,并且我安装了 firebase_core: ^0.4.0+9。但是,当我尝试运行该应用程序时,出现以下错误

import 'dart:html';
       ^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/js-0.6.2/lib/js.dart:8:1: Error: Not found: 'dart:js'
export 'dart:js' show allowInterop, allowInteropCaptureThis;
^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/js-0.6.2/lib/js_util.dart:8:1: Error: Not found: 'dart:js_util'
export 'dart:js_util';
^
lib/main.dart:19:47: Error: Getter not found: 'Firebase'.
  final Future<FirebaseApp> _initialization = Firebase.initializeApp();
                                              ^^^^^^^^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/auth.dart:306:25: Error: The method 'allowInterop' isn't defined for the class 'Auth'.
 - 'Auth' is from 'package:firebase/src/auth.dart' ('../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/auth.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
      var nextWrapper = allowInterop((firebase_interop.UserJsImpl user) {
                        ^^^^^^^^^^^^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/auth.dart:310:26: Error: The method 'allowInterop' isn't defined for the class 'Auth'.
 - 'Auth' is from 'package:firebase/src/auth.dart' ('../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/auth.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
      var errorWrapper = allowInterop((e) => _changeController.addError(e));
                         ^^^^^^^^^^^^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/auth.dart:340:25: Error: The method 'allowInterop' isn't defined for the class 'Auth'.
 - 'Auth' is from 'package:firebase/src/auth.dart' ('../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/auth.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
      var nextWrapper = allowInterop((firebase_interop.UserJsImpl user) {
                        ^^^^^^^^^^^^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/auth.dart:345:11: Error: The method 'allowInterop' isn't defined for the class 'Auth'.
 - 'Auth' is from 'package:firebase/src/auth.dart' ('../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/auth.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
          allowInterop((e) => _idTokenChangedController.addError(e));
          ^^^^^^^^^^^^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/database.dart:164:9: Error: The method 'allowInterop' isn't defined for the class 'DatabaseReference<T>'.
 - 'DatabaseReference' is from 'package:firebase/src/database.dart' ('../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/database.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
        allowInterop((update) => jsify(transactionUpdate(dartify(update))));
        ^^^^^^^^^^^^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/database.dart:166:26: Error: The method 'allowInterop' isn't defined for the class 'DatabaseReference<T>'.
 - 'DatabaseReference' is from 'package:firebase/src/database.dart' ('../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/database.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
    var onCompleteWrap = allowInterop(
                         ^^^^^^^^^^^^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/database.dart:301:24: Error: The method 'allowInterop' isn't defined for the class 'Query<T>'.
 - 'Query' is from 'package:firebase/src/database.dart' ('../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/database.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
    var callbackWrap = allowInterop((database_interop.DataSnapshotJsImpl data,
                       ^^^^^^^^^^^^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/database.dart:325:30: Error: The method 'allowInterop' isn't defined for the class 'Query<T>'.
 - 'Query' is from 'package:firebase/src/database.dart' ('../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/database.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
    jsObject.once(eventType, allowInterop(
                             ^^^^^^^^^^^^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/database.dart:402:22: Error: The method 'allowInterop' isn't defined for the class 'DataSnapshot'.
 - 'DataSnapshot' is from 'package:firebase/src/database.dart' ('../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/database.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
    var actionWrap = allowInterop((d) => action(DataSnapshot.getInstance(d)));
                     ^^^^^^^^^^^^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/messaging.dart:72:27: Error: The method 'allowInterop' isn't defined for the class 'Messaging'.
 - 'Messaging' is from 'package:firebase/src/messaging.dart' ('../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/messaging.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
      final nextWrapper = allowInterop((payload) {
                          ^^^^^^^^^^^^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/messaging.dart:75:28: Error: The method 'allowInterop' isn't defined for the class 'Messaging'.
 - 'Messaging' is from 'package:firebase/src/messaging.dart' ('../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/messaging.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
      final errorWrapper = allowInterop((e) {
                           ^^^^^^^^^^^^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/messaging.dart:87:27: Error: The method 'allowInterop' isn't defined for the class 'Messaging'.
 - 'Messaging' is from 'package:firebase/src/messaging.dart' ('../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/messaging.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
      final nextWrapper = allowInterop((payload) {
                          ^^^^^^^^^^^^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/messaging.dart:97:27: Error: The method 'allowInterop' isn't defined for the class 'Messaging'.
 - 'Messaging' is from 'package:firebase/src/messaging.dart' ('../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/messaging.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
      final nextWrapper = allowInterop((_) => null);
                          ^^^^^^^^^^^^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/messaging.dart:98:28: Error: The method 'allowInterop' isn't defined for the class 'Messaging'.
 - 'Messaging' is from 'package:firebase/src/messaging.dart' ('../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/messaging.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
      final errorWrapper = allowInterop((e) {
                           ^^^^^^^^^^^^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/storage.dart:317:11: Error: The method 'allowInterop' isn't defined for the class 'UploadTask'.
 - 'UploadTask' is from 'package:firebase/src/storage.dart' ('../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/storage.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
          allowInterop((storage_interop.UploadTaskSnapshotJsImpl data) {
          ^^^^^^^^^^^^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/storage.dart:321:26: Error: The method 'allowInterop' isn't defined for the class 'UploadTask'.
 - 'UploadTask' is from 'package:firebase/src/storage.dart' ('../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/storage.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
      var errorWrapper = allowInterop((e) => _changeController.addError(e));
                         ^^^^^^^^^^^^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/storage.dart:322:26: Error: The method 'allowInterop' isn't defined for the class 'UploadTask'.
 - 'UploadTask' is from 'package:firebase/src/storage.dart' ('../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/storage.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
      var onCompletion = allowInterop(() {
                         ^^^^^^^^^^^^
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.2/lib/src/top_level.dart:196:7: Error: Method not found: 'hasProperty'.
  if (js.hasProperty(error, 'message')) {
      ^^^^^^^^^^^```

我不知道该怎么做,因为错误是关于 HTML 和 js 文件的,而我只使用 dart 进行移动开发。我还删除了我的测试小部件和文件夹,这可能是问题吗?

【问题讨论】:

    标签: firebase flutter dart


    【解决方案1】:

    只需尝试删除“import 'dart:html';”从你的进口。

    【讨论】:

      【解决方案2】:

      找到导入语句import 'dart:html'; 并将其删除。

      【讨论】:

        【解决方案3】:

        您能检查一下您的导入部分是否包含“dart.html”吗? 如果是,请将其删除并重建。

        【讨论】:

          【解决方案4】:

          您可以通过删除不使用的import 'package:firebase/firebase.dart'; 来解决它。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2021-07-22
            • 2019-02-28
            • 2021-02-05
            • 2021-07-04
            • 2021-09-26
            • 2020-03-11
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多