首页 > 解决方案 > Flutter 依赖错误 (flutter_svg: ^0.19.2+1)

问题描述

当我尝试添加 flutter_svg 依赖项以在我的项目中添加 SVG 格式图片时,它会抛出这样的错误: 在此处输入图像描述

/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.19.2+1/lib/src/picture_provider.dart:57: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) {

我正在使用颤振(频道主,1.26.0-18.0.pre.193)。和flutter_svg:^0.19.2+1

我也使用了此依赖项的较低版本,但仍然出现相同的错误。

标签: androidflutterflutter-dependenciesmobile-development

解决方案


添加以下依赖项

flutter_svg:^0.20.0-nullsafety.3

代替

颤振_svg:^0.19.2+1

然后按照这些步骤

  1. 扑干净
  2. 扑吧酒吧
  3. 扑跑

推荐阅读