try 在Web浏览器中运行Flutter 应用程序时出错.

以下是我在运行该应用程序时获得的输出:

Launching lib/main.dart on Chrome in debug mode...

Waiting for connection from debug service on Chrome...
../../../.pub-cache/hosted/pub.dartlang.org/wav

e-0.1.0/lib/config.dart:46:13: Error: Method not found: 'throwNullError'.
                throwNullError('custom', 'colors` or `gradients');
                ^^^^^^^^^^^^^^
    ../../../.pub-cache/hosted/pub.dartlang.org/wave-0.1.0/lib/config.dart:60:13: Error: Method not found: 'throwNullError'.
                throwNullError('custom', 'durations');
                ^^^^^^^^^^^^^^
    ../../../.pub-cache/hosted/pub.dartlang.org/wave-0.1.0/lib/config.dart:66:13: Error: Method not found: 'throwNullError'.
                throwNullError('custom', 'heightPercentages');
                ^^^^^^^^^^^^^^
    ../../../.pub-cache/hosted/pub.dartlang.org/flutter_platform_widgets-0.60.2/lib/src/platform_app_bar.dart:209:9: Error: No named parameter with the name 'actionsForegroundColor'.
            actionsForegroundColor: data?.actionsForegroundColor,
            ^^^^^^^^^^^^^^^^^^^^^^
    ../../FlutterProjects/SDK/flutter/packages/flutter/lib/src/cupertino/nav_bar.dart:220:9: Context: Found this candidate, but the arguments don't match.
      const CupertinoNavigationBar({
            ^^^^^^^^^^^^^^^^^^^^^^
    ../../../.pub-cache/hosted/pub.dartlang.org/flutter_platform_widgets-0.60.2/lib/src/platform_app_bar.dart:229:7: Error: No named parameter with the name 'actionsForegroundColor'.
          actionsForegroundColor: data?.actionsForegroundColor,
          ^^^^^^^^^^^^^^^^^^^^^^
    ../../FlutterProjects/SDK/flutter/packages/flutter/lib/src/cupertino/nav_bar.dart:220:9: Context: Found this candidate, but the arguments don't match.
      const CupertinoNavigationBar({
            ^^^^^^^^^^^^^^^^^^^^^^
    ../../../.pub-cache/hosted/pub.dartlang.org/flutter_neumorphic-3.0.3/lib/src/widget/app_bar.dart:147:57: Error: No named parameter with the name 'nullOk'.
        final ScaffoldState scaffold = Scaffold.of(context, nullOk: true);
                                                            ^^^^^^
    ../../FlutterProjects/SDK/flutter/packages/flutter/lib/src/material/scaffold.dart:1930:24: Context: Found this candidate, but the arguments don't match.
      static ScaffoldState of(BuildContext context) {
                           ^^
    ../../FlutterProjects/SDK/flutter/packages/flutter_localizations/lib/src/material_localizations.dart:413:7: Error: Method 'replaceFirst' cannot be called on 'String?' because it is potentially null.
    Try calling using ?. instead.
        ).replaceFirst(r'$selectedRowCount', formatDecimal(selectedRowCount));
          ^^^^^^^^^^^^
    ../../FlutterProjects/SDK/flutter/packages/flutter_localizations/lib/src/material_localizations.dart:550:7: Error: Method 'replaceFirst' cannot be called on 'String?' because it is potentially null.
    Try calling using ?. instead.
        ).replaceFirst(r'$licenseCount', formatDecimal(licenseCount));
          ^^^^^^^^^^^^
    ../../FlutterProjects/SDK/flutter/packages/flutter_localizations/lib/src/material_localizations.dart:659:7: Error: Method 'replaceFirst' cannot be called on 'String?' because it is potentially null.
    Try calling using ?. instead.
        ).replaceFirst(r'$remainingCount', formatDecimal(remainingCount));
          ^^^^^^^^^^^^
    ../../../.pub-cache/hosted/pub.dartlang.org/chewie-0.9.10/lib/src/chewie_player.dart:83:7: Error: No named parameter with the name 'resizeToAvoidBottomPadding'.
          resizeToAvoidBottomPadding: false,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
    ../../FlutterProjects/SDK/flutter/packages/flutter/lib/src/material/scaffold.dart:1437:9: Context: Found this candidate, but the arguments don't match.
      const Scaffold({
            ^^^^^^^^
    ../../../.pub-cache/hosted/pub.dartlang.org/chewie-0.9.10/lib/src/chewie_player.dart:276:17: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
     - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../FlutterProjects/SDK/flutter/packages/flutter/lib/src/widgets/framework.dart').
    Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
            context.inheritFromWidgetOfExactType(_ChewieControllerProvider)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Failed to compile application.

以下是我的Flutter doctor 输出:

[✓] Flutter (Channel master, 1.26.0-2.0.pre.419, on macOS 11.1 20C69 darwin-x64, locale en-GB)
    • Flutter version 1.26.0-2.0.pre.419 at /Users/sanket/Desktop/FlutterProjects/SDK/flutter
    • Framework revision 913d5933c1 (4 hours ago), 2021-01-19 22:34:03 -0800
    • Engine revision b58dbc88fc
    • Dart version 2.12.0 (build 2.12.0-240.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/sanket/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/sanket/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode2.app/Contents/Developer
    • Xcode 12.0, Build version 12A7209
    ! Xcode 12.0.0 out of date (12.0.1 is recommended).
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.10.0

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

[✓] Android Studio (version 4.1)
    • 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 1.8.0_242-release-1644-b3-6915495)

[✓] Connected device (2 available)
    • AOSP on IA Emulator (mobile) • emulator-5554 • android-x86    • Android 9 (API 28) (emulator)
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 87.0.4280.141

! Doctor found issues in 1 category.
Process finished with exit code 0

enter image description here

请帮我解决这个错误,我的应用程序之前在浏览器中运行,但我不知道它什么时候停止工作.

我试着升级了Flutter 翼和dart 的版本来解决这个问题,但是仍然不能工作.

推荐答案

我也犯了同样的错误,我试过了

flutter clean

然后

dart pub upgrade

用于依赖项升级.

然后 it started working you can just click on the Pub Upgrade in Android studio in pubspec.yml file of your projects.

Flutter相关问答推荐

如何让一个名为ONTAP的回调函数、另一个名为onTapDown的回调函数和另一个名为onTapUp的回调函数不重叠?

Flutter -如何停止块监听程序在后台堆栈中运行

为什么我的PIN字段在第一次打字时不显示数字?

Flutter 动画列表一次构建所有项目,而不是仅构建可见的项目

在创建显示此错误的Flutter 深度链接时

DART:如何判断有时可以为空的泛型类型?

为Android生成时出现Flutter 错误:给定资源值的<;COLOR&>无效

Flutter卡内容未在水平列表视图中居中

flutter Listview构建器溢出

Flutter Riverpod 没有捕获 List 的嵌套值变化

Flutter 火焰相机抖动已弃用

在使用 Android 12+ 的真实 Android 设备上,SingleChildScrollView 中最初位于视口之外的无响应 Web 视图

创建混合 TextWidget 和 TextFieldWidget

使 Row 中的元素保持在中间的空间,如果它们太大,则将它们包裹起来

Flutter blue plus 库,当try 从 esp32 驱动程序获取 PlatformException 时读取特性

Flutter 动保存新的变量值

是否有可能减少代码的编写,例如:ref.read(countProvider.notifier) - 在构建方法中?

Flutter - 定义按钮的优雅方式

从物理设备 Flutter 中移除 USB 后启动画面不可见?

Flutter Desktop,如何获取windows用户配置文件名称?