【问题标题】:Fluter app run error : Execution failed for task ':app:compileFlutterBuildDebug'Flutter 应用程序运行错误:任务“:app:compileFlutterBuildDebug”执行失败
【发布时间】:2021-09-26 06:35:45
【问题描述】:

当我尝试运行我的颤振项目时,我收到了这个错误。

Fluter 应用运行错误:任务 ':app:compileFlutterBuildDebug' 执行失败

调试:

Launching lib\main.dart on AOSP on IA Emulator in debug mode...
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.18.1/lib/src/picture_provider.dart:50:59: Error: No named parameter with the name 'nullOk'.
        context != null ? Localizations.localeOf(context, nullOk: true) : null,
                                                          ^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/localizations.dart:413:17: Context: Found this candidate, but the arguments don't match.

  static Locale localeOf(BuildContext context) {
                ^^^^^^^^

FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org
BUILD FAILED in 12s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

我的 main.dart 文件如下所示:

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      theme: ThemeData(
        textTheme: Theme.of(context).textTheme.apply(bodyColor: kTextColor),
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: HomeScreen(),
    );
  }
}

有人知道怎么解决吗?

更新: 在 pubspec.yaml 中运行 flutter pub get 并不能解决问题。

【问题讨论】:

  • 这是您的错误:50:59:错误:没有名为“nullOk”的命名参数。上下文!=空? Localizations.localeOf(context, nullOk: true) : null
  • 它说它在颤振的源文件夹中。我不认为我可以编辑它?

标签: android flutter dart mobile


【解决方案1】:

按照以下步骤操作:

  1. 添加以下依赖或最新版本

flutter_svg: ^0.20.0-nullsafety.3

  1. 运行flutter pub get 命令

【讨论】:

    猜你喜欢
    • 2021-09-25
    • 2022-07-04
    • 1970-01-01
    • 2022-07-04
    • 2021-08-21
    • 2021-11-22
    • 1970-01-01
    • 1970-01-01
    • 2021-12-08
    相关资源
    最近更新 更多