Md. Sabik Alam Rahat
Md. Sabik Alam Rahat

Reputation: 157

Flutter Dependency Error (flutter_svg: ^0.19.2+1)

When I try to add flutter_svg dependency to add SVG format picture in my project it throws me an error like that: enter image description here

/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) {

I'm using flutter (Channel master, 1.26.0-18.0.pre.193). and flutter_svg: ^0.19.2+1

I've also with a lower version of this dependency, but still the same error.

Upvotes: 0

Views: 4042

Answers (5)

Usama Elgendy
Usama Elgendy

Reputation: 576

I solved this problem by delete nullOk: true from this line because Localizations.localeOf take context only as a parameter

locale:
    context != null ? Localizations.localeOf(context) : null,

instead of

locale:
    context != null ? Localizations.localeOf(context, nullOk: true) : null,

or you can change your channel from master channel to stable channel by using this command line on your terminal.

flutter channel stable flutter clean

Upvotes: 0

Rojith Peiris
Rojith Peiris

Reputation: 201

add the following dependency

flutter_svg: ^0.20.0-nullsafety.3

instead of

flutter_svg: ^0.19.2+1

Then follow these steps

  1. flutter clean
  2. flutter pub get
  3. flutter run

Upvotes: 2

Ravinder Kumar
Ravinder Kumar

Reputation: 8010

I am using flutter beta version as I am using beta to develop my website, this issue also came to me today, I solved it by running this command,

flutter downgrade

Upvotes: 0

Vadim Popov
Vadim Popov

Reputation: 772

Looks like flutter_svg didn't migrate to nullsafety, try switch to stable channel and repair cache files.

1. flutter channel stable
2. flutter clean
3. flutter pub cache repair 
4. flutter packages get
5. flutter run

If this does not help then try this https://github.com/dnfield/flutter_svg/issues/479

Upvotes: 0

Dan Gerchcovich
Dan Gerchcovich

Reputation: 525

Yeah, this was an issue for me when I was working on the master branch for a recent project. It was an issue which only came up for the flutter internalisation package.

The main issue is with the intl package: https://pub.dev/packages/intl/install

To fix this, below the dependencies, please add another section, that will override the intl dependency, which is being pulled by the flutter_localizations package:

dependency_overrides:
  intl: ^0.17.0-nullsafety.2

It should now work for the master branch. Another tip, you should avoid working on the master branch, because master changes all the time. You should stick to either stable or beta.

Upvotes: 0

Related Questions