Flutter Web错误:需要一个类型为“Object”的值,但得到的是一个类型为“Null”的值#115332

inb24sb2  于 2023-05-23  发布在  Flutter
关注(0)|答案(1)|浏览(175)

在Web上运行flutter时出错
我认为错误来自Firebase核心。我的项目在Android上运行得很顺利。

错误:需要“Object”类型的值,但得到的是“Null”类型的值
错误输出

Error: Expected a value of type 'Object', but got one of type 'Null'

C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49 throw_ C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/\_internal/js_dev_runtime/private/ddc_runtime/errors.dart 99:3 castError C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/\_internal/js_dev_runtime/private/ddc_runtime/operations.dart 470:10 cast C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/\_internal/js_dev_runtime/patch/core_patch.dart 73:24 as packages/firebase_core_web/src/firebase_core_web.dart 64:20 get \[\_ignoredServiceScripts\] packages/firebase_core_web/src/firebase_core_web.dart 115:28 \_initializeCore C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/\_internal/js_dev_runtime/patch/async_patch.dart 85:54 runBody C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/\_internal/js_dev_runtime/patch/async_patch.dart 124:5 \_async packages/firebase_core_web/src/firebase_core_web.dart 107:31 \[\_initializeCore\] packages/firebase_core_web/src/firebase_core_web.dart 149:11 initializeApp C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/\_internal/js_dev_runtime/patch/async_patch.dart 85:54 runBody C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/\_internal/js_dev_runtime/patch/async_patch.dart 124:5 \_async packages/firebase_core_web/src/firebase_core_web.dart 145:44 initializeApp packages/firebase_core/src/firebase.dart 43:47 initializeApp C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/\_internal/js_dev_runtime/patch/async_patch.dart 85:54 runBody C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/\_internal/js_dev_runtime/patch/async_patch.dart 124:5 \_async packages/firebase_core/src/firebase.dart 39:43 initializeApp packages/swivenetworkproject/main.dart 28:18 main C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/\_internal/js_dev_runtime/patch/async_patch.dart 85:54 runBody C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/\_internal/js_dev_runtime/patch/async_patch.dart 124:5 \_async packages/swivenetworkproject/main.dart 26:18 main$ web_entrypoint.dart 24:31 \<fn\> C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/\_internal/js_dev_runtime/private/ddc_runtime/operations.dart 352:37 \_checkAndCall C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/\_internal/js_dev_runtime/private/ddc_runtime/operations.dart 357:39 dcall C:/b/s/w/ir/cache/builder/src/out/host_debug/lib/ui/initialization.dart 77:15 \<fn\> C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/\_internal/js_dev_runtime/patch/async_patch.dart 46:50 \<fn\> C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1660:54 runUnary C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 147:18 handleValue C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 767:44 handleValueCallback C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 796:13 \_propagateToListeners C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 567:5 \[\_completeWithValue\] C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 640:7 callback C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 40:11 \_microtaskLoop C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 49:5 \_startMicrotaskLoop C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/\_internal/js_dev_runtime/patch/async_patch.dart 167:15 \<fn\>

Flutter doctor -v output

\[√\] Flutter (Channel master, 3.5.0-10.0.pre.58, on Microsoft Windows \[Version 10.0.19043.2251\], locale tr-TR) • Flutter version 3.5.0-10.0.pre.58 on channel master at C:\\src\\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 0c14308404 (3 weeks ago), 2022-10-24 14:31:17 -0700 • Engine revision f445898c1a • Dart version 2.19.0 (build 2.19.0-330.0.dev) • DevTools version 2.18.0

\[√\] Windows Version (Installed version of Windows is version 10 or higher)

\[√\] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at C:\\Users\\monst\\AppData\\Local\\Android\\sdk • Platform android-33, build-tools 30.0.3 • Java binary at: C:\\Program Files\\Android\\Android Studio\\jre\\bin\\java • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822) • All Android licenses accepted.

\[√\] Chrome - develop for the web • Chrome at C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe

\[!\] Visual Studio - develop for Windows (Visual Studio Derleme Araçları 2019 16.11.18) • Visual Studio at C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools • Visual Studio Derleme Araçları 2019 version 16.11.32802.440 X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components: MSVC v142 - VS 2019 C++ x64/x86 build tools - If there are multiple build tool versions available, install the latest C++ CMake tools for Windows Windows 10 SDK

\[√\] Android Studio (version 2021.1) • Android Studio at C:\\Program Files\\Android\\Android Studio • 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.11+9-b60-7590822)

\[√\] VS Code (version 1.73.1) • VS Code at C:\\Users\\monst\\AppData\\Local\\Programs\\Microsoft VS Code • Flutter extension version 3.52.0

\[√\] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows \[Version 10.0.19043.2251\] • Chrome (web) • chrome • web-javascript • Google Chrome 107.0.5304.107 • Edge (web) • edge • web-javascript • Microsoft Edge 107.0.1418.42

\[√\] HTTP Host Availability • All required HTTP hosts are available

! Doctor found issues in 1 category.

我的pubspec.yaml包

\#db
firebase_auth: ^4.1.2
firebase_core: ^2.2.0
firebase_crashlytics: ^3.0.5
cloud_firestore: ^4.0.2
firebase_database: ^10.0.1
firebase_messaging: ^14.1.0
\#web
firebase_core_web: ^2.0.1
firebase_analytics_web: ^0.5.1+4
firebase_auth_web: ^5.1.2
firebase_messaging_web: ^3.2.6
cloud_firestore_web: ^3.0.5

flutter_core_web的输出

imzjd6km

imzjd6km1#

_ignoredServiceScripts getter代码片段显示了一个try-catch,因此它不应该抛出错误。
您应该为未捕获的异常而不是所有异常设置断点。
如果您在调试面板上使用VSCode,则在启动调试器时会看到以下选项:breakpoint in VSCode
如果做不到这一点,请确保您的Firebase配置根据official instructions正确设置。
另请参阅此GitHub问题。希望这能解决问题。

相关问题