尝试运行 flutter web 的开发版本时出现 TypeError

问题描述 投票:0回答:1

我不知道它什么时候停止在网络上运行。我知道以前也是这样然而,现在每当我尝试在网络上运行我的应用程序的调试版本时,它都会抛出 TypeError 错误。

日志:

Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
This app is linked to the debug service: ws://127.0.0.1:54101/Qknz_K4xs_g=/ws
Debug service listening on ws://127.0.0.1:54101/Qknz_K4xs_g=/ws
Debug service listening on ws://127.0.0.1:54101/Qknz_K4xs_g=/ws
Error: TypeError: Instance of 'ArgumentError': type 'ArgumentError' is not a subtype of type 'JavaScriptObject'
dart:sdk_internal 11932:11                                                    throw_
dart:sdk_internal 24589:15                                                    _failedAsCheck
dart:sdk_internal 24575:14                                                    _generalAsCheckImplementation
app/packages/_flutterfire_internals/_flutterfire_internals.dart.lib.js 70:38  _testException
dart:sdk_internal 49595:59                                                    runUnary
dart:sdk_internal 44726:29                                                    matchesErrorTest
dart:sdk_internal 45337:30                                                    handleError
dart:sdk_internal 45364:17                                                    _propagateToListeners
dart:sdk_internal 45207:23                                                    [_completeError]
dart:sdk_internal 45250:31                                                    callback
dart:sdk_internal 50044:13                                                    _microtaskLoop
dart:sdk_internal 50050:13                                                    _startMicrotaskLoop
dart:sdk_internal 45591:9                                                     <fn>
Application finished.

颤医生-v:

[✓] Flutter (Channel stable, 3.19.6, on macOS 14.4.1 23E224 darwin-arm64, locale en-US)
    • Flutter version 3.19.6 on channel stable at /Users/canyon/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (2 days ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/canyon/Library/Android/sdk
    • Platform android-34, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A240d
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
    • 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 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.86.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.82.0

[✓] Connected device (3 available)
    • iPhone 15 Pro (mobile) • 9E000980-FB8A-459B-86AD-0AECD6B15485 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 124.0.6367.61
    ! Error: Browsing on the local area network for Canyon's Developer iPhone. Ensure the device is unlocked and attached with a cable or associated with the same
      local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for Canyon's iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area
      network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for Canyon’s Apple Watch. Ensure the device is unlocked and discoverable via Bluetooth. (code -27)
    ! Error: Browsing on the local area network for DavidiPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area
      network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

• No issues found!

我不知道为什么会这样。

  1. 我已经删除了所有与网络不兼容的 pub 依赖项。
  2. 我已经跑了
    flutter clean
  3. 我已经更新了所有 pub 依赖项
  4. 我已经对这个主题进行了研究。没有出现任何与我的问题真正相符的内容。

谢谢您的帮助!

flutter typeerror
1个回答
0
投票

在我之前处理网络相关问题的经验中,我也遇到过类似的挑战。通过下面概述的初步调查步骤,我已成功识别并解决了此类问题。此外,我根据您的反馈考虑了可能有助于问题解决的注意事项。

  • 既然您提到它曾经在网络上运行,请考虑一下任何 您最近对代码库所做的更改,尤其是相关的更改 特定于平台的代码或依赖项。

  • 您遇到的错误,TypeError: 'ArgumentError'实例:类型'ArgumentError'不是类型'JavaScriptObject'的子类型表明您的代码中某处发生了类型不匹配,特别是在与JavaScript交互时。检查与 JavaScript 交互的所有代码,例如通过 dart:js 或外部 JavaScript 库。确保传递的类型与预期匹配。

  • _flutterfire_internals.dart.lib.js 表明该错误可能与 FlutterFire 有关,FlutterFire 是一组启用 Firebase 支持的 Flutter 插件。如果您使用 FlutterFire,请检查您的集成并确保其与网络兼容。

  • 如果您有特定于平台的代码,并且在 Web 上执行方式不同 与其他平台相比,确保它能够正确处理 网络特定案例。

仔细检查您的代码,您应该能够识别并解决导致问题的类型错误。

© www.soinside.com 2019 - 2024. All rights reserved.