使用flutter_svg包时如何解决此nullOk错误? [英] How to fix this nullOk error when using the flutter_svg package?
本文介绍了使用flutter_svg包时如何解决此nullOk错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我连接了程序包,将其添加到main.dart中,我尝试编译该应用程序,但出现此错误.帮助!我该怎么办?
I connected the package, added it to main.dart, I try to compile the application, but I get this error. Help! What should I do about it?
错误
Launching lib\main.dart on XT1562 in debug mode...
Running Gradle task 'assembleDebug'...
/D:/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,
^^^^^^
/D:/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:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\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 15s
Exception: Gradle task assembleDebug failed with exit code 1
推荐答案
请遵循以下步骤
- 添加以下依赖项
flutter_svg: ^0.20.0-nullsafety.3
- 运行
flutter clean
命令 - 运行
flutter pub get
命令 - 运行
flutter run
命令或运行项目
- run
flutter clean
command - run
flutter pub get
command - run
flutter run
command or run the project
这篇关于使用flutter_svg包时如何解决此nullOk错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文