gpt4 book ai didi

flutter - 使用 flutter_svg 包时如何修复这个 nullOk 错误?

转载 作者:行者123 更新时间:2023-12-03 16:29:23 25 4
gpt4 key购买 nike

我连接了包,将它添加到 main.dart,我尝试编译应用程序,但出现此错误。帮助!我该怎么办?
错误

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命令或运行项目
  • 关于flutter - 使用 flutter_svg 包时如何修复这个 nullOk 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66144283/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com