Reputation: 157
When I try to add flutter_svg dependency to add SVG format picture in my project it throws me an error like that:
/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
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
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
Upvotes: 2
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
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
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