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



当我尝试运行flutter项目时,我会收到这个错误。

Flutter应用程序运行错误:任务":app:compileFlutterBuildDebug"执行失败

调试:

Launching libmain.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:srcflutterpackagesflutter_toolsgradleflutter.gradle' line: 1035
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:srcflutterbinflutter.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并不能解决问题。

按照以下步骤操作:

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

flatter_svg:^0.20.0-完全安全。3

  1. 运行flutter pub get命令

最新更新