Anm*_*ahu 3 debugging dart android-studio flutter
我将我的应用程序更新到最新版本的 Flutter。\nE:\\anmol\\Jan\' 2021 -Backup\\nemar_user_(for_new_packages)>flutter --version\nFlutter 2.0.3 \xe2\x80\xa2 通道稳定\xe2\x80\xa2 https://github.com/flutter/flutter.git \n框架 \xe2\x80\xa2 修订版 4d7946a68d (3 天前) \xe2\x80\xa2 2021-03-18 17:24:33 -0700\n引擎 \xe2\x80\xa2 修订版 3459eb2436\n工具 \xe2\x80\xa2 Dart 2.12.2
\nAlong with that, I upgraded new packages in pubspec.yaml\nWhen I run my app, then it shows the following errors, I tried so many things but nothing Works. Any Kind of Help would be appreciated.
\n/E:/flutterSDK/flutter/.pub-cache/hosted/pub.dartlang.org/expandable_text-1.3.2/lib/expandable_text.dart:153:56: Error: No named parameter with the name \'nullOk\'.\nfinal locale = Localizations.localeOf(context, nullOk: true);\n^^^^^^\n/E:/flutterSDK/flutter/packages/flutter/lib/src/widgets/localizations.dart:413:17: Context: Found this candidate, but the arguments don\'t match.\nstatic Locale localeOf(BuildContext context) {\n^^^^^^^^
\nFAILURE: Build failed with an exception.
\nWhere:\nScript \'E:\\flutterSDK\\flutter\\packages\\flutter_tools\\gradle\\flutter.gradle\' line: 991
\nWhat went wrong:\nExecution failed for task \':app:compileFlutterBuildDebug\'.
\n\n\nProcess \'command \'E:\\flutterSDK\\flutter\\bin\\flutter.bat\'\' finished with non-zero exit value 1
\n
Try:\nRun 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.
\nGet more help at https://help.gradle.org
\nBUILD FAILED in 46s\nException: Gradle task assembleDebug failed with exit code 1
\n这是因为您使用的 Flutter 版本(稳定通道,Flutter 2.0.3)启用了 null-safety。这些API 可能会发生更改,因此您需要使用此迁移指南来修改代码,以使用具有 null 安全性的新形式的 API。
方法一:
检查您是否正在使用任何上述 API 依赖项并.maybeOf(context)
使用.of(context, nullOk: true);
在您发布的代码中,将您的更改Localizations.localeOf(context, nullOk: true);
为Localizations.maybeLocaleOf(context);
方法二:
找到导致问题的依赖项并将其更新为空安全性,例如,如果您正在使用,flutter_svg: ^0.19.0
您会遇到相同的错误,因此要么将其更新为flutter_svg: ^0.20.0-nullsafety.3
,要么如果您还无法迁移到空安全性,请使用此版本flutter_svg: ^0.19.3
方法三:
或者,您也可以降级不提供 null 安全性的 Flutter 版本。它还应该修复错误,但需要降级。要降级到 v1.22.6,请运行以下命令:
flutter downgrade v1.22.6
Run Code Online (Sandbox Code Playgroud)
在每个/任何方法之后,运行以下命令:
flutter clean
flutter pub get
flutter run
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2120 次 |
最近记录: |