我的应用程序运行正常,在运行 flutter upgrade 后它给了我这个错误。我没有改变我的代码中的任何内容。 注意:我正在使用 Visual Studio 代码 我试过flutter clean,flutter upgrade,但它给出了同样的错误。 我检查了 JAVA_HOME 路径,没问题
../../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,
^^^^^^
../../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 'D:\mobileapps\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\mobileapps\flutter\bin\flutter.bat'' finished with non-zero exit value 1
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 49s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 50.5s
Exception: Gradle task assembleDebug failed with exit code 1
这是运行医生 -v 的结果
[√] Flutter (Channel stable, 2.0.1, on Microsoft Windows [Version 10.0.18362.30], locale en-US)
• Flutter version 2.0.1 at D:\mobileapps\flutter
• Framework revision c5a4b4029c (7 days ago), 2021-03-04 09:47:48 -0800
• Engine revision 40441def69
• Dart version 2.12.0
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
• Android SDK at C:\Users\hit-ham\AppData\Local\Android\sdk
• Platform android-29, build-tools 30.0.1
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 47.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
rosoft VS Code
• Flutter extension version 3.20.0
[√] Connected device (2 available)
• GM1910 (mobile) • bb671501 • android-arm64 • Android 10 (API 29)
• Chrome (web) • chrome • web-javascript • Google Chrome 88.0.4324.190
• No issues found!
答案 0 :(得分:0)
您应该将包“flutter_svg”从 0.18.1 更新到 0.19.3,它应该可以解决您的问题, 这是因为 Flutter 2 中删除了 'nullOk' 参数。你可以在这里阅读它: https://flutter.dev/docs/release/breaking-changes/eliminating-nullok-parameters
我找到了这个解决方案,它对我有用